Class: Apia::Yabeda::PrometheusCollector
- Inherits:
-
Object
- Object
- Apia::Yabeda::PrometheusCollector
- Defined in:
- lib/apia/yabeda/prometheus_collector.rb
Instance Method Summary collapse
Instance Method Details
#register_metrics ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/apia/yabeda/prometheus_collector.rb', line 21 def register_metrics ::Yabeda.configure do group :apia do counter :requests_total do comment "The total number of requests handled by Apia" ([:method, :route, :status, :api, :endpoint, :authenticator, :error_code]) end histogram :endpoint_duration do comment "Time spent in Apia requests in seconds" unit :seconds ([:status, :endpoint]) buckets ::Yabeda::Rails::LONG_RUNNING_REQUEST_BUCKETS end end end end |
#start ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/apia/yabeda/prometheus_collector.rb', line 11 def start register_metrics ActiveSupport::Notifications.subscribe(/(request(_error)?)\.apia/) do |*args| event = ActiveSupport::Notifications::Event.new(*args) increment_request_total_metric(event) observe_endpoint_duration_metric(event) end end |