Module: PhobosPrometheus::Collector::Helper
Overview
Shared code between collectors. Using module to avoid introducing inheritance
Instance Attribute Summary collapse
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Instance Method Summary collapse
-
#safely_update_metrics(event) ⇒ Object
rubocop:disable Lint/RescueWithoutErrorClass.
- #setup_collector_module(instrumentation:) ⇒ Object
- #subscribe_metrics ⇒ Object
Instance Attribute Details
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
8 9 10 |
# File 'lib/phobos_prometheus/collector/helper.rb', line 8 def registry @registry end |
Instance Method Details
#safely_update_metrics(event) ⇒ Object
rubocop:disable Lint/RescueWithoutErrorClass
26 27 28 29 30 31 |
# File 'lib/phobos_prometheus/collector/helper.rb', line 26 def safely_update_metrics(event) event_label = EVENT_LABEL_BUILDER.call(event) update_metrics(event_label, event) rescue => error ErrorLogger.new(error, event, @instrumentation).log end |
#setup_collector_module(instrumentation:) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/phobos_prometheus/collector/helper.rb', line 10 def setup_collector_module(instrumentation:) @instrumentation = instrumentation @registry = Prometheus::Client.registry @metrics_prefix = PhobosPrometheus.config.metrics_prefix || 'phobos_client' init_metrics(instrumentation.sub('.', '_')) subscribe_metrics end |
#subscribe_metrics ⇒ Object
19 20 21 22 23 |
# File 'lib/phobos_prometheus/collector/helper.rb', line 19 def subscribe_metrics Phobos::Instrumentation.subscribe(@instrumentation) do |event| safely_update_metrics(event) end end |