Class: Deimos::Metrics::Manager
- Inherits:
-
Object
- Object
- Deimos::Metrics::Manager
- Defined in:
- lib/deimos/metrics/manager.rb
Constant Summary collapse
- TYPES =
{ counter: Prometheus::Client::Counter, gauge: Prometheus::Client::Gauge, histogram: Prometheus::Client::Histogram, summary: Prometheus::Client::Summary }
Instance Attribute Summary collapse
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Instance Method Summary collapse
- #collectors ⇒ Object
-
#initialize(registry: Prometheus::Client.registry) ⇒ Manager
constructor
A new instance of Manager.
- #subscribe(event_name, type:, label:, **kwargs, &block) ⇒ Object
Constructor Details
#initialize(registry: Prometheus::Client.registry) ⇒ Manager
Returns a new instance of Manager.
14 15 16 |
# File 'lib/deimos/metrics/manager.rb', line 14 def initialize(registry: Prometheus::Client.registry) @registry = registry end |
Instance Attribute Details
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
13 14 15 |
# File 'lib/deimos/metrics/manager.rb', line 13 def registry @registry end |
Instance Method Details
#collectors ⇒ Object
18 19 20 |
# File 'lib/deimos/metrics/manager.rb', line 18 def collectors @collectors ||= {} end |
#subscribe(event_name, type:, label:, **kwargs, &block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/deimos/metrics/manager.rb', line 22 def subscribe(event_name, type:, label:, **kwargs, &block) Deimos.logger.info "Metrics: Subscribed to #{event_name}..." ActiveSupport::Notifications.subscribe(event_name) do |*args| event = ActiveSupport::Notifications::Event.new(*args) collector = register_collector!(event_name, type, label, kwargs) if block_given? yield(event, collector) else Deimos.logger.info event end end end |