yabeda-rails 0.1.3 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61cf4aa1c51939cf818ad3333aa18146c13905bbf4cf106b40e87a351fe0c3b9
4
- data.tar.gz: f18e2d6896b0fba6d1df1fb9818d3b38241a0435ebf75482ffb4ea1a631c3842
3
+ metadata.gz: 7dbf65d3d54b48f0ed4140e72734407e1cd67babb934c797e3f2dd65e7e6c177
4
+ data.tar.gz: 6c186927d6d13ee387751cddd625c29d03ec974c2d80cf72d16ea3c0a971cd6f
5
5
  SHA512:
6
- metadata.gz: 5a579fff0e19c4d43db8b957aebeffdf9eaa313a954a7942965219aecc81735b677061f7d2b03eac7b922a7d03176a7f6fcc831765acd9859550a820467d6ac7
7
- data.tar.gz: 760f14baec9e99021b40b43a571ea49e15f10867ad01d3c17cd44b5c169f4258ed8c82c2db94489d70484af97b8cda8873574952354275d32cf24a61c1fb2e43
6
+ metadata.gz: 4795bd4a4c82f002f2ef6d6b3620ce8ae4e5bb92a7d81da3117153bf7f2f2e6fbbeb28bab45572d5efaeea11aa4690eef6ecc594980d3f2dbf282588dceb1b37
7
+ data.tar.gz: 4b20c62e48cf0ba9be1726efe214f990ff3f2d319ed2bb75d24fafe95d03d9672c60d89cff30df7774b8cec191459f8186738cc8755d456cae4d3b2bbf8d5ca7
@@ -1,5 +1,5 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.5.1
5
- before_install: gem install bundler -v 1.16.1
4
+ - 2.7.1
5
+ before_install: gem install bundler -v 2.0
@@ -5,6 +5,35 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 0.7.0 - 2020-08-21
9
+
10
+ ### Removed
11
+
12
+ - Railtie to configure Yabeda – it is moved into Yabeda itself. Increase required Yabeda version to keep behavior for users who require only `yabeda-rails` in their Gemfiles. @Envek
13
+
14
+ ## 0.6.0 - 2020-08-06
15
+
16
+ ### Added
17
+
18
+ - Ability to add default/custom tags to metrics from controllers. @raivil in [#13](https://github.com/yabeda-rb/yabeda-rails/pull/13)
19
+
20
+ ## 0.5.0 - 2020-03-27
21
+
22
+ ### Added
23
+
24
+ - Support for Unicorn application server. @vast in [#9](https://github.com/yabeda-rb/yabeda-rails/pull/9)
25
+
26
+ ## 0.4.0 - 2020-01-28
27
+
28
+ ### Changed
29
+
30
+ - Configure Yabeda after application initialization as since 0.4.0 Yabeda requires to call configuration logic explicitly. @Envek
31
+
32
+ ## 0.2.0 - 2020-01-14
33
+
34
+ ### Changed
35
+
36
+ - Added `tags` option to metric declarations for compatibility with yabeda and yabeda-prometheus 0.2. @Envek
8
37
 
9
38
  ## 0.1.2 - 2019-01-19
10
39
 
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # Yabeda::[Rails]
2
2
 
3
- Built-in metrics for out-of-the box [Rails] applications monitoring
3
+ Built-in metrics for out-of-the box [Rails] applications monitoring.
4
4
 
5
- if your monitoring system already collects Rails metrics (e.g. NewRelic) then you don't need this gem.
5
+ If your monitoring system already collects Rails metrics (e.g. NewRelic) then most probably you don't need this gem.
6
+
7
+ Sample Grafana dashboard ID: [11668](https://grafana.com/grafana/dashboards/11668)
6
8
 
7
9
  ## Installation
8
10
 
@@ -20,7 +22,7 @@ And then execute:
20
22
 
21
23
  ### Registering metrics on server process start
22
24
 
23
- Currently, yabeda-rails automatically registers rails metrics when a server is started via `rails server` or `puma -C config/puma.rb`. However, other application servers or launching via `rackup` aren't supported at the moment.
25
+ Currently, yabeda-rails automatically registers rails metrics when a server is started via `rails server`, `puma -C config/puma.rb` or `unicorn -c`. However, other application servers or launching via `rackup` aren't supported at the moment.
24
26
 
25
27
  A possible workaround is to detect server process and manually activate yabeda-rails in an initializer:
26
28
 
@@ -32,7 +34,7 @@ if your_app_server_process? # Your logic here
32
34
  end
33
35
  ```
34
36
 
35
- You always can add support for your app server to [lib/yabeda/rails/railtie.rb](). Pull Requests are always welcome!
37
+ You always can add support for your app server to [lib/yabeda/rails/railtie.rb](lib/yabeda/rails/railtie.rb). Pull Requests are always welcome!
36
38
 
37
39
 
38
40
  ## Metrics
@@ -55,6 +57,26 @@ You always can add support for your app server to [lib/yabeda/rails/railtie.rb](
55
57
  end
56
58
  ```
57
59
 
60
+ ## Custom tags
61
+
62
+ You can add additional tags to the existing metrics by adding custom payload to your controller.
63
+
64
+ ```ruby
65
+ # This block is optional but some adapters (like Prometheus) requires that all tags should be declared in advance
66
+ Yabeda.configure do
67
+ default_tag :importance, nil
68
+ end
69
+
70
+ class ApplicationController < ActionController::Base
71
+ def append_info_to_payload(payload)
72
+ super
73
+ payload[:importance] = extract_importance(params)
74
+ end
75
+ end
76
+ ```
77
+ `append_info_to_payload` is a method from [ActionController::Instrumentation](https://api.rubyonrails.org/classes/ActionController/Instrumentation.html#method-i-append_info_to_payload)
78
+
79
+
58
80
  ## Development
59
81
 
60
82
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -23,13 +23,21 @@ module Yabeda
23
23
  Yabeda.configure do
24
24
  group :rails
25
25
 
26
- counter :requests_total, comment: "A counter of the total number of HTTP requests rails processed."
27
- histogram :request_duration, unit: :seconds, buckets: LONG_RUNNING_REQUEST_BUCKETS,
26
+ counter :requests_total, comment: "A counter of the total number of HTTP requests rails processed.",
27
+ tags: %i[controller action status format method]
28
+
29
+ histogram :request_duration, tags: %i[controller action status format method],
30
+ unit: :seconds,
31
+ buckets: LONG_RUNNING_REQUEST_BUCKETS,
28
32
  comment: "A histogram of the response latency."
33
+
29
34
  histogram :view_runtime, unit: :seconds, buckets: LONG_RUNNING_REQUEST_BUCKETS,
30
- comment: "A histogram of the view rendering time."
35
+ comment: "A histogram of the view rendering time.",
36
+ tags: %i[controller action status format method]
37
+
31
38
  histogram :db_runtime, unit: :seconds, buckets: LONG_RUNNING_REQUEST_BUCKETS,
32
- comment: "A histogram of the activerecord execution time."
39
+ comment: "A histogram of the activerecord execution time.",
40
+ tags: %i[controller action status format method]
33
41
 
34
42
  ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*args|
35
43
  event = ActiveSupport::Notifications::Event.new(*args)
@@ -39,7 +47,7 @@ module Yabeda
39
47
  status: event.payload[:status],
40
48
  format: event.payload[:format],
41
49
  method: event.payload[:method].downcase,
42
- }
50
+ }.merge!(event.payload.slice(*Yabeda.default_tags.keys))
43
51
 
44
52
  rails_requests_total.increment(labels)
45
53
  rails_request_duration.measure(labels, Yabeda::Rails.ms2s(event.duration))
@@ -11,10 +11,12 @@ module Yabeda
11
11
  ::Rails.const_defined?('Puma::CLI')
12
12
  end
13
13
 
14
- config.after_initialize do
15
- next unless rails_server? || puma_server?
14
+ def unicorn_server?
15
+ ::Rails.const_defined?("Unicorn::Launcher")
16
+ end
16
17
 
17
- ::Yabeda::Rails.install!
18
+ initializer "yabeda-rails.metrics" do
19
+ ::Yabeda::Rails.install! if rails_server? || puma_server? || unicorn_server?
18
20
  end
19
21
  end
20
22
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yabeda
4
4
  module Rails
5
- VERSION = "0.1.3"
5
+ VERSION = "0.7.0"
6
6
  end
7
7
  end
@@ -22,10 +22,10 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
24
 
25
- spec.add_dependency "yabeda"
25
+ spec.add_dependency "yabeda", "~> 0.8"
26
26
  spec.add_dependency "rails"
27
27
 
28
- spec.add_development_dependency "bundler", "~> 1.16"
29
- spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "bundler", "~> 2.0"
29
+ spec.add_development_dependency "rake", "~> 13.0"
30
30
  spec.add_development_dependency "rspec", "~> 3.0"
31
31
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yabeda-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Novikov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-21 00:00:00.000000000 Z
11
+ date: 2020-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yabeda
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '0.8'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '0.8'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.16'
47
+ version: '2.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.16'
54
+ version: '2.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '10.0'
61
+ version: '13.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '10.0'
68
+ version: '13.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  requirements: []
124
- rubygems_version: 3.0.1
124
+ rubygems_version: 3.1.2
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: Extensible metrics for monitoring Ruby on Rails application