Module: Legion::Metrics
- Defined in:
- lib/legion/metrics.rb
Class Attribute Summary collapse
-
.registry ⇒ Object
readonly
Returns the value of attribute registry.
Class Method Summary collapse
Class Attribute Details
.registry ⇒ Object (readonly)
Returns the value of attribute registry.
18 19 20 |
# File 'lib/legion/metrics.rb', line 18 def registry @registry end |
Class Method Details
.available? ⇒ Boolean
6 7 8 |
# File 'lib/legion/metrics.rb', line 6 def available? defined?(Prometheus::Client) ? true : false end |
.refresh_gauges ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/legion/metrics.rb', line 26 def refresh_gauges return unless available? @metrics[:uptime].set(::Process.clock_gettime(::Process::CLOCK_MONOTONIC)) refresh_active_workers refresh_rolling_window end |
.render ⇒ Object
20 21 22 23 24 |
# File 'lib/legion/metrics.rb', line 20 def render return '' unless available? Prometheus::Client::Formats::Text.marshal(@registry) end |
.reset! ⇒ Object
34 35 36 37 38 39 |
# File 'lib/legion/metrics.rb', line 34 def reset! @registry = nil @metrics = nil @listeners&.each { |name, block| Legion::Events.off(name, block) if defined?(Legion::Events) } @listeners = {} end |
.setup ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/legion/metrics.rb', line 10 def setup return unless available? init_registry init_metrics register_event_listeners end |