active_endpoint 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +55 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +60 -0
  5. data/.travis.yml +5 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +25 -0
  8. data/Gemfile.lock +140 -0
  9. data/LICENSE +21 -0
  10. data/README.md +233 -0
  11. data/Rakefile +6 -0
  12. data/active_endpoint.gemspec +28 -0
  13. data/app/assets/config/active_endpoint_manifest.js +2 -0
  14. data/app/assets/javascripts/active_endpoint/application.js +2 -0
  15. data/app/assets/stylesheets/active_endpoint/application.css +10 -0
  16. data/app/controllers/active_endpoint/application_controller.rb +5 -0
  17. data/app/controllers/active_endpoint/dashboard_controller.rb +7 -0
  18. data/app/controllers/active_endpoint/probes_controller.rb +22 -0
  19. data/app/controllers/active_endpoint/unregistred_probes_controller.rb +14 -0
  20. data/app/helpers/active_endpoint/application_helper.rb +105 -0
  21. data/app/models/active_endpoint/application_record.rb +5 -0
  22. data/app/models/active_endpoint/probe.rb +52 -0
  23. data/app/models/active_endpoint/unregistred_probe.rb +3 -0
  24. data/app/views/active_endpoint/application/_flashes.html.erb +5 -0
  25. data/app/views/active_endpoint/application/_header.html.erb +18 -0
  26. data/app/views/active_endpoint/dashboard/_blacklist.html.erb +57 -0
  27. data/app/views/active_endpoint/dashboard/_constraints.html.erb +117 -0
  28. data/app/views/active_endpoint/dashboard/_settings.html.erb +13 -0
  29. data/app/views/active_endpoint/dashboard/_tags.html.erb +20 -0
  30. data/app/views/active_endpoint/dashboard/index.html.erb +8 -0
  31. data/app/views/active_endpoint/probes/index.html.erb +28 -0
  32. data/app/views/active_endpoint/probes/show.html.erb +43 -0
  33. data/app/views/active_endpoint/probes/show_response.html.erb +9 -0
  34. data/app/views/active_endpoint/unregistred_probes/index.html.erb +28 -0
  35. data/app/views/layouts/active_endpoint/application.html.erb +39 -0
  36. data/bin/console +14 -0
  37. data/bin/rails +13 -0
  38. data/bin/setup +8 -0
  39. data/config/routes.rb +8 -0
  40. data/lib/active_endpoint.rb +60 -0
  41. data/lib/active_endpoint/concerns/configurable.rb +29 -0
  42. data/lib/active_endpoint/concerns/constraintable.rb +51 -0
  43. data/lib/active_endpoint/concerns/optionable.rb +41 -0
  44. data/lib/active_endpoint/concerns/rails_routable.rb +49 -0
  45. data/lib/active_endpoint/engine.rb +15 -0
  46. data/lib/active_endpoint/extentions/active_record.rb +30 -0
  47. data/lib/active_endpoint/logger.rb +28 -0
  48. data/lib/active_endpoint/proxy.rb +64 -0
  49. data/lib/active_endpoint/rails/middleware.rb +17 -0
  50. data/lib/active_endpoint/rails/railtie.rb +13 -0
  51. data/lib/active_endpoint/request.rb +79 -0
  52. data/lib/active_endpoint/response.rb +17 -0
  53. data/lib/active_endpoint/routes/blacklist.rb +67 -0
  54. data/lib/active_endpoint/routes/cache/proxy.rb +22 -0
  55. data/lib/active_endpoint/routes/cache/proxy/redis_store_proxy.rb +41 -0
  56. data/lib/active_endpoint/routes/cache/store.rb +73 -0
  57. data/lib/active_endpoint/routes/constraint_rule.rb +38 -0
  58. data/lib/active_endpoint/routes/constraints.rb +81 -0
  59. data/lib/active_endpoint/routes/matcher.rb +51 -0
  60. data/lib/active_endpoint/routes/momento.rb +81 -0
  61. data/lib/active_endpoint/storage.rb +112 -0
  62. data/lib/active_endpoint/tags.rb +15 -0
  63. data/lib/active_endpoint/version.rb +3 -0
  64. data/lib/generators/active_endpoint/install_generator.rb +35 -0
  65. data/lib/generators/templates/active_endpoint.rb +40 -0
  66. data/lib/generators/templates/migration.erb +30 -0
  67. metadata +109 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 346454b7c0b01487e60199e3f011c93240993054
4
+ data.tar.gz: f8ab721004f110a1f18ab81b5f408f1d418ccaea
5
+ SHA512:
6
+ metadata.gz: ddcd450fa6e5ad910972196c914a8534012c785f7752647f3297826442ec139780b68b5cd8a84568f38cddf6ed65579d21c60ec3d0a30b78f17528b9105c1cde
7
+ data.tar.gz: c4274afb609b577a43754be3d21cbaf111badea6fecbf2059ef90a7ed37f5fb037b6fefbfb0758d6e33ed79acbfe956b9d7ccff2a0856e414a75c4cbedaa36d2
@@ -0,0 +1,55 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
51
+
52
+ # other
53
+ /.rspec_status
54
+ /.byebug_history
55
+ /dump.rdb
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,60 @@
1
+ Documentation:
2
+ Enabled: false
3
+
4
+ Style/Encoding:
5
+ Enabled: false
6
+
7
+ Metrics/LineLength:
8
+ Max: 120
9
+
10
+ Metrics/MethodLength:
11
+ Max: 25
12
+
13
+ Metrics/AbcSize:
14
+ Max: 30
15
+
16
+ Lint/DefEndAlignment:
17
+ # The value `def` means that `end` should be aligned with the def keyword.
18
+ # The value `start_of_line` means that `end` should be aligned with method
19
+ # calls like `private`, `public`, etc, if present in front of the `def`
20
+ # keyword on the same line.
21
+ EnforcedStyleAlignWith: start_of_line
22
+ SupportedStylesAlignWith:
23
+ - start_of_line
24
+ - def
25
+ AutoCorrect: true
26
+
27
+ # Align ends correctly.
28
+ Lint/EndAlignment:
29
+ # The value `keyword` means that `end` should be aligned with the matching
30
+ # keyword (`if`, `while`, etc.).
31
+ # The value `variable` means that in assignments, `end` should be aligned
32
+ # with the start of the variable on the left hand side of `=`. In all other
33
+ # situations, `end` should still be aligned with the keyword.
34
+ # The value `start_of_line` means that `end` should be aligned with the start
35
+ # of the line which the matching keyword appears on.
36
+ EnforcedStyleAlignWith: keyword
37
+ SupportedStylesAlignWith:
38
+ - keyword
39
+ - variable
40
+ - start_of_line
41
+ AutoCorrect: true
42
+
43
+ Rails/UniqBeforePluck:
44
+ EnforcedStyle: conservative
45
+ SupportedStyles:
46
+ - conservative
47
+ - aggressive
48
+ AutoCorrect: true
49
+
50
+
51
+ # Checks whether the source file has a utf-8 encoding comment or not
52
+ # AutoCorrectEncodingComment must match the regex
53
+ # /#.*coding\s?[:=]\s?(?:UTF|utf)-8/
54
+ Style/Encoding:
55
+ EnforcedStyle: when_needed
56
+ SupportedStyles:
57
+ - when_needed
58
+ - always
59
+ - never
60
+ AutoCorrectEncodingComment: '# encoding: utf-8'
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.14.3
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at marat@khusnetdinov.ru. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,25 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Declare your gem's dependencies in active_endpoint.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ # Declare any dependencies that are still in development here instead of in
9
+ # your gemspec. These might include edge Rails or gems from your path or
10
+ # Git. Remember to move these dependencies to your gemspec before releasing
11
+ # your gem to rubygems.org.
12
+
13
+ gem 'activesupport', '~> 4.1.11'
14
+ gem 'rack', '~> 1.0'
15
+ gem 'redis-activesupport'
16
+
17
+ gem 'sass-rails'
18
+
19
+ group :development do
20
+ gem 'bundler', '~> 1.14'
21
+ gem 'rake', '~> 10.0'
22
+ gem 'reek'
23
+ gem 'rspec', '~> 3.0'
24
+ gem 'rubocop'
25
+ end
@@ -0,0 +1,140 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ active_endpoint (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actionpack (4.1.16)
10
+ actionview (= 4.1.16)
11
+ activesupport (= 4.1.16)
12
+ rack (~> 1.5.2)
13
+ rack-test (~> 0.6.2)
14
+ actionview (4.1.16)
15
+ activesupport (= 4.1.16)
16
+ builder (~> 3.1)
17
+ erubis (~> 2.7.0)
18
+ activesupport (4.1.16)
19
+ i18n (~> 0.6, >= 0.6.9)
20
+ json (~> 1.7, >= 1.7.7)
21
+ minitest (~> 5.1)
22
+ thread_safe (~> 0.1)
23
+ tzinfo (~> 1.1)
24
+ ast (2.3.0)
25
+ axiom-types (0.1.1)
26
+ descendants_tracker (~> 0.0.4)
27
+ ice_nine (~> 0.11.0)
28
+ thread_safe (~> 0.3, >= 0.3.1)
29
+ builder (3.2.3)
30
+ codeclimate-engine-rb (0.4.0)
31
+ virtus (~> 1.0)
32
+ coercible (1.0.0)
33
+ descendants_tracker (~> 0.0.1)
34
+ concurrent-ruby (1.0.5)
35
+ descendants_tracker (0.0.4)
36
+ thread_safe (~> 0.3, >= 0.3.1)
37
+ diff-lcs (1.3)
38
+ equalizer (0.0.11)
39
+ erubis (2.7.0)
40
+ ffi (1.9.18)
41
+ i18n (0.8.6)
42
+ ice_nine (0.11.2)
43
+ json (1.8.6)
44
+ minitest (5.10.3)
45
+ parallel (1.12.0)
46
+ parser (2.4.0.0)
47
+ ast (~> 2.2)
48
+ powerpack (0.1.1)
49
+ rack (1.5.5)
50
+ rack-test (0.6.3)
51
+ rack (>= 1.0)
52
+ railties (4.1.16)
53
+ actionpack (= 4.1.16)
54
+ activesupport (= 4.1.16)
55
+ rake (>= 0.8.7)
56
+ thor (>= 0.18.1, < 2.0)
57
+ rainbow (2.2.2)
58
+ rake
59
+ rake (10.5.0)
60
+ rb-fsevent (0.10.2)
61
+ rb-inotify (0.9.10)
62
+ ffi (>= 0.5.0, < 2)
63
+ redis (3.3.3)
64
+ redis-activesupport (5.0.3)
65
+ activesupport (>= 3, < 6)
66
+ redis-store (~> 1.3.0)
67
+ redis-store (1.3.0)
68
+ redis (>= 2.2)
69
+ reek (4.7.2)
70
+ codeclimate-engine-rb (~> 0.4.0)
71
+ parser (>= 2.4.0.0, < 2.5)
72
+ rainbow (~> 2.0)
73
+ rspec (3.6.0)
74
+ rspec-core (~> 3.6.0)
75
+ rspec-expectations (~> 3.6.0)
76
+ rspec-mocks (~> 3.6.0)
77
+ rspec-core (3.6.0)
78
+ rspec-support (~> 3.6.0)
79
+ rspec-expectations (3.6.0)
80
+ diff-lcs (>= 1.2.0, < 2.0)
81
+ rspec-support (~> 3.6.0)
82
+ rspec-mocks (3.6.0)
83
+ diff-lcs (>= 1.2.0, < 2.0)
84
+ rspec-support (~> 3.6.0)
85
+ rspec-support (3.6.0)
86
+ rubocop (0.49.1)
87
+ parallel (~> 1.10)
88
+ parser (>= 2.3.3.1, < 3.0)
89
+ powerpack (~> 0.1)
90
+ rainbow (>= 1.99.1, < 3.0)
91
+ ruby-progressbar (~> 1.7)
92
+ unicode-display_width (~> 1.0, >= 1.0.1)
93
+ ruby-progressbar (1.8.1)
94
+ sass (3.5.1)
95
+ sass-listen (~> 4.0.0)
96
+ sass-listen (4.0.0)
97
+ rb-fsevent (~> 0.9, >= 0.9.4)
98
+ rb-inotify (~> 0.9, >= 0.9.7)
99
+ sass-rails (5.0.6)
100
+ railties (>= 4.0.0, < 6)
101
+ sass (~> 3.1)
102
+ sprockets (>= 2.8, < 4.0)
103
+ sprockets-rails (>= 2.0, < 4.0)
104
+ tilt (>= 1.1, < 3)
105
+ sprockets (3.7.1)
106
+ concurrent-ruby (~> 1.0)
107
+ rack (> 1, < 3)
108
+ sprockets-rails (3.2.0)
109
+ actionpack (>= 4.0)
110
+ activesupport (>= 4.0)
111
+ sprockets (>= 3.0.0)
112
+ thor (0.19.4)
113
+ thread_safe (0.3.6)
114
+ tilt (2.0.8)
115
+ tzinfo (1.2.3)
116
+ thread_safe (~> 0.1)
117
+ unicode-display_width (1.3.0)
118
+ virtus (1.0.5)
119
+ axiom-types (~> 0.1)
120
+ coercible (~> 1.0)
121
+ descendants_tracker (~> 0.0, >= 0.0.3)
122
+ equalizer (~> 0.0, >= 0.0.9)
123
+
124
+ PLATFORMS
125
+ ruby
126
+
127
+ DEPENDENCIES
128
+ active_endpoint!
129
+ activesupport (~> 4.1.11)
130
+ bundler (~> 1.14)
131
+ rack (~> 1.0)
132
+ rake (~> 10.0)
133
+ redis-activesupport
134
+ reek
135
+ rspec (~> 3.0)
136
+ rubocop
137
+ sass-rails
138
+
139
+ BUNDLED WITH
140
+ 1.14.3
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Marat Khusnetdinov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,233 @@
1
+ # ActiveEndpoint [![Build Status](https://travis-ci.org/khusnetdinov/active_endpoint.svg?branch=master)](https://travis-ci.org/khusnetdinov/active_endpoint) [![Gem Version](https://badge.fury.io/rb/active_endpoint.svg)](https://badge.fury.io/rb/active_endpoint)
2
+
3
+ ## Your request tracking tool for rails applications
4
+
5
+ ## Attention! Gem in under active test and is preparing for first release !
6
+
7
+ ![img](http://res.cloudinary.com/dtoqqxqjv/image/upload/c_scale,w_346/v1501331806/github/active_probe.jpg)
8
+
9
+
10
+ ## Usage
11
+
12
+ ActiveEndpoint is middleware for Rails applications that collects and analyses requests and responses per request for endpoint. It works with minimal impact on application's response time.
13
+
14
+ This gem uses `ActiveSupport::Notifications` and `Cache Storage` to reduce possible impact on application request / response processing time.
15
+
16
+ ## Features
17
+
18
+ - Metrics are stored in database for further tracking and analysis.
19
+ - History rotation with configurable limits of records amount and age.
20
+ - Routes filter (blacklist).
21
+ - Probes tagging by processing time.
22
+
23
+ ## Metrics
24
+
25
+ These endpoint metrics are stored in DB:
26
+
27
+ - `:uuid` - uniq probe identifier
28
+ - `:endpoint` - requested endpoint
29
+ - `:path` - requested full path
30
+ - `:query_string` - request query string
31
+ - `:request_method` - http request method
32
+ - `:ip` - ip address asked request
33
+ - `:url` - request full url
34
+ - `:xhr` - is request ajax?
35
+ - `:started_at` - probe start time
36
+ - `:finished_at` - probe finish time
37
+ - `:duration` - probe request duration
38
+ - `:params` - parsed requested params
39
+ - `:response` - Base64 encoded html response
40
+ - `:body` - Base64 encoded request body
41
+
42
+ Additional information is taken from Rack log:
43
+
44
+ `:base_url, :content_charset, :content_length, :content_type, :fullpath, :http_version, :http_connection, :http_accept_encoding, :http_accept_language, :media_type, :media_type_params, :method, :path_info, :pattern, :port, :protocol, :server_name, :ssl`.
45
+
46
+ Requests which are not recognized by rails router are stored as `unregistred`.
47
+
48
+ ## Requirements
49
+
50
+ - `redis` as cache storage
51
+
52
+ Be sure that you have all requrements installed on you machine.
53
+
54
+ ## Installation
55
+
56
+ Add this line to your application's Gemfile:
57
+
58
+ ```ruby
59
+ gem 'active_endpoint'
60
+ ```
61
+
62
+ And then execute:
63
+
64
+ $ bundle
65
+
66
+ Or install it yourself as:
67
+
68
+ $ gem install active_endpoint
69
+
70
+ Setup project for using gem:
71
+
72
+ $ rails generate active_endpoint:install
73
+
74
+ Migrate database for models:
75
+
76
+ $ rake db:migrate # Rails <=4
77
+ $ rails db:migrate # Rails >=5
78
+
79
+ Now project has all files and settings that allow you to use gem.
80
+
81
+ ## Configuration
82
+
83
+ ### Endpoints filter (blacklist)
84
+
85
+ By default ActiveEndpoint treats all routes as `whitelist` routes. To filter some endpoints you can use `blackilist` configuration, as shown below:
86
+
87
+ ```ruby
88
+ ActiveEndpoint.configure do |endpoint|
89
+ endpoint.blacklist.configure do |blacklist|
90
+ # Ignore endpoint "welcome#index"
91
+ blacklist.add(endpoint: "welcome#index")
92
+
93
+ # Ignore "web/users" controller actions
94
+ blacklist.add(resources: ["web/users"])
95
+
96
+ # Ignore "web/users#show" action with scoped controller
97
+ blacklist.add(scope: "web", resources: "users", actions: ["show"])
98
+
99
+ # Ignore "admin" scope controllers
100
+ blacklist.add(scope: "admin")
101
+ end
102
+ end
103
+ ```
104
+
105
+ #### Ignore one endpoint
106
+
107
+ `blacklist.add(endpoint: "users#index")` - Ignore one endpoint.
108
+
109
+ #### Ignore controller actions
110
+
111
+ `blacklist.add(resources: "users")` - Ignore all actions for `UsersController`.
112
+
113
+ `blacklist.add(resources: ["users", "managers"])` - Ignore all actions in `UsersController` and `ManagersController`.
114
+
115
+ `blacklist.add(resources: "users", actions: ["show"])` - Ignore only `show` action in `UsersController`.
116
+
117
+ #### Ignore namespace or scope
118
+
119
+ `blacklist.add(scope: "admin")` - Ignore all controllers and actions for `admin` namespace or scope.
120
+
121
+ ### Constraints
122
+
123
+ You can specify the amount and period of request records to keep in database. Records which exceed these limits are automatically removed from database.
124
+ See example below:
125
+
126
+ ```ruby
127
+ ActiveEndpoint.configure do |endpoint|
128
+ # Defines default settings, 1 probe per 10 minutes for endpoint request
129
+ constraint_limit = 1
130
+ constraint_period = 10.minutes
131
+
132
+ endpoint.constraints.configure do |constraints|
133
+ # Constraint endpoint "welcome#index" with 1 minute period and default limit
134
+ # and configure database constraints to keep 1000 probes per 1 week.
135
+ constraints.add(endpoint: "welcome#index",
136
+ rule: { 1.minute },
137
+ storage: { limit: 1000, period: 1.week })
138
+ # Constraints "web/users" controller actions with custom limit and period
139
+ # with defailt storage constraints
140
+ constraints.add(resources: ["web/users"], rule: { limit: 100, period: 5.minutes })
141
+ end
142
+ end
143
+ ```
144
+ NOTE: To define a constraint you should define at least one limit or period.
145
+
146
+ ### Storage settings
147
+
148
+ ActiveEndpoint creates two models in you rails application: `Probe` and it's child `UnregistredProbe`.
149
+ To prevent problems with database probes are removed when user defines custom period. Also you can limit storage probes in database.
150
+ It is recommended to define own storage default to prevent unwanted probes deletion. See example below:
151
+
152
+ ```ruby
153
+ ActiveEndpoint.configure do |endpoint|
154
+ # Define default limit for maximum probes amount
155
+ endpoint.storage_limit = 1000
156
+
157
+ # Define default period to keep probes in database.
158
+ endpoint.storage_period = 1.week
159
+
160
+ # Define amount of periods (constraint periods) that endpoints are kept in database.
161
+ endpoint.storage_keep_periods = 2
162
+ end
163
+ ```
164
+
165
+ ### Tagging probes
166
+ You can group probes by tags automatically assigned according to request processing time (ms). See example below:
167
+
168
+ ```ruby
169
+ ActiveEndpoint.configure do |endpoint|
170
+ endpoint.tags.configure do |tags|
171
+ tags.add(:fast, { less_than: 250 })
172
+ tags.add(:normal, { greater_than_or_equal_to: 250, less_than: 500 })
173
+ tags.add(:slow, { greater_than_or_equal_to: 500, less_than: 750 })
174
+ tags.add(:acceptable, { greater_than_or_equal_to: 500, less_than: 1000 })
175
+ tags.add(:need_optimization, { greater_than_or_equal_to: 1000 })
176
+ end
177
+ end
178
+ ```
179
+
180
+ #### Mehods for conditions
181
+
182
+ - greater_than = '>'
183
+ - greater_than_or_equal_to = '>=',
184
+ - equal_to = '=',
185
+ - less_than = '<',
186
+ - less_than_or_equal_to = '<=',
187
+
188
+ #### Tagged model scopes
189
+
190
+ Defined tags are also usefull for scopes queries:
191
+
192
+ ```ruby
193
+ ActiveEndpoint::Probe.tagged_as(:need_optimization)
194
+ #=> Returns all probes having corresponding tag and thus matching the condition
195
+ # { greater_than_or_equal_to: 1000 }
196
+ ```
197
+
198
+ #### Instance methods
199
+
200
+ Check tag on model:
201
+
202
+ ```ruby
203
+ ActiveEndpoint::Probe.last.tag
204
+ #=> Returns probe's tag
205
+ ```
206
+ ### Logging
207
+
208
+ Logger settings:
209
+
210
+ ```ruby
211
+ ActiveEndpoint.configure do |endpoint|
212
+ # Logger
213
+ define_setting :logger, ActiveEndpoint::Logger
214
+ # Set to true if you want to log probe's additional information
215
+ define_setting :log_probe_info, false
216
+ # Set to true for debugging, recomended for development
217
+ define_setting :log_debug_info, false
218
+ end
219
+ ```
220
+
221
+ ### Web UI
222
+
223
+ ActiveEndpoint offer rails engine for managing probes. Mount it:
224
+
225
+ ```ruby
226
+ mount ActiveEndpoint::Engine => '/active_endpoint'
227
+ ```
228
+
229
+ ![img](http://res.cloudinary.com/dtoqqxqjv/image/upload/v1502260319/github/%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA_%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0_2017-08-09_%D0%B2_9.06.08_mmwh5d.png)
230
+
231
+ ## License
232
+
233
+ This gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).