yabeda-rails 0.1.2 → 0.6.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: fa6080838a84371c2f8b813d8f2e613f15dbdddeb2c4281b63eff6368a26aae0
4
- data.tar.gz: bba458511569e406752c603e5d897415227dac7edb84c58ae80148c88beaa352
3
+ metadata.gz: 17430310dde26c291834ba76e124506f4cd913578d18f6fbb9c8a1caa2967776
4
+ data.tar.gz: f978a2034421966bd6e8dcc38f2e1f2ab644c3cb3627c6bf94a73f5cd46fee00
5
5
  SHA512:
6
- metadata.gz: 3df4bbd07f750e0d32d6b84a894ac74c130fc64844dce69bd8ad9b3e445f7ca61972308528ebadd78d4a0b67198199b203e7b9b881f37ef0d8baae06baac2fb4
7
- data.tar.gz: 41dd0f1141cd22e182b2e0c4461a712aa1ecb9de97d233b4b03d726345c93c82cb863c1b1752525d05d4e0195d1d3486a0bd9f43c5567eb7ae9fd824407fcf40
6
+ metadata.gz: 62b667631fad16ce7b6436109e14484509c8c54e3bd41a4c744fdabc62f34b22b9a86bc861c6df369d1ce74f2eee6d8ebb4c7dbd89971b48d7feb16892e92a13
7
+ data.tar.gz: 40adc80e926e70ba662b1c9fd6f32872a35a689fa127993037ee3e5b5272325c4d9a2fa25433dc17b6a225f60ecaab333661b7e5555e7d6fdf78e459466454fe
@@ -5,6 +5,29 @@ 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.6.0 - 2020-08-06
9
+
10
+ ### Added
11
+
12
+ - Ability to add default/custom tags to metrics from controllers. @raivil in [#13](https://github.com/yabeda-rb/yabeda-rails/pull/13)
13
+
14
+ ## 0.5.0 - 2020-03-27
15
+
16
+ ### Added
17
+
18
+ - Support for Unicorn application server. @vast in [#9](https://github.com/yabeda-rb/yabeda-rails/pull/9)
19
+
20
+ ## 0.4.0 - 2020-01-28
21
+
22
+ ### Changed
23
+
24
+ - Configure Yabeda after application initialization as since 0.4.0 Yabeda requires to call configuration logic explicitly. @Envek
25
+
26
+ ## 0.2.0 - 2020-01-14
27
+
28
+ ### Changed
29
+
30
+ - Added `tags` option to metric declarations for compatibility with yabeda and yabeda-prometheus 0.2. @Envek
8
31
 
9
32
  ## 0.1.2 - 2019-01-19
10
33
 
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 you don't need this gem metrics, but `yabeda-rails` also will automatically configure Yabeda in your Rails application.
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))
@@ -3,12 +3,6 @@
3
3
  module Yabeda
4
4
  module Rails
5
5
  class Railtie < ::Rails::Railtie # :nodoc:
6
- config.after_initialize do
7
- next unless rails_server? || puma_server?
8
-
9
- ::Yabeda::Rails.install!
10
- end
11
-
12
6
  def rails_server?
13
7
  ::Rails.const_defined?(:Server)
14
8
  end
@@ -16,6 +10,15 @@ module Yabeda
16
10
  def puma_server?
17
11
  ::Rails.const_defined?('Puma::CLI')
18
12
  end
13
+
14
+ def unicorn_server?
15
+ ::Rails.const_defined?("Unicorn::Launcher")
16
+ end
17
+
18
+ config.after_initialize do
19
+ ::Yabeda::Rails.install! if rails_server? || puma_server? || unicorn_server?
20
+ Yabeda.configure! unless Yabeda.already_configured?
21
+ end
19
22
  end
20
23
  end
21
24
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yabeda
4
4
  module Rails
5
- VERSION = "0.1.2"
5
+ VERSION = "0.6.0"
6
6
  end
7
7
  end
@@ -22,7 +22,7 @@ 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.4"
26
26
  spec.add_dependency "rails"
27
27
 
28
28
  spec.add_development_dependency "bundler", "~> 1.16"
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.2
4
+ version: 0.6.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-19 00:00:00.000000000 Z
11
+ date: 2020-08-06 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.4'
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.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails
29
29
  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