Module: Phronomy::Metrics
- Defined in:
- lib/phronomy/metrics.rb
Overview
Task-centric observability snapshot (Issue #276, extended in #307).
Collects live metrics from the shared Runtime components (BlockingAdapterPool, EventLoop, and Runtime task registry) and returns them as a plain Hash so they can be forwarded to any monitoring backend (Prometheus, OpenTelemetry, StatsD, etc.).
All metrics are read at the moment Metrics.snapshot is called; no persistent state is held here.
Class Method Summary collapse
-
.snapshot ⇒ Hash{Symbol => Numeric}
Returns a Hash of current observability metrics.
Class Method Details
.snapshot ⇒ Hash{Symbol => Numeric}
Returns a Hash of current observability metrics.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/phronomy/metrics.rb', line 22 def self.snapshot pool = Runtime.instance.blocking_io el = EventLoop.instance task_snap = Runtime.instance.task_snapshot { blocking_pool_active: pool.active_count, blocking_pool_queue_length: pool.queue_depth, blocking_pool_abandoned_total: pool.abandoned_count, blocking_pool_size: pool.pool_size, event_loop_lag_last_ms: (el.last_lag_seconds * 1000).round(3), event_loop_lag_max_ms: (el.max_lag_seconds * 1000).round(3), event_loop_lag_average_ms: (el.average_lag_seconds * 1000).round(3) }.merge(task_snap) end |