Class: StandardHealth::Notifiers::Metrics
- Inherits:
-
Object
- Object
- StandardHealth::Notifiers::Metrics
- Defined in:
- lib/standard_health/notifiers/metrics.rb
Overview
Emits per-check and per-evaluation metrics.
Unlike the Logger and Sentry notifiers, this one fires on EVERY poll on purpose. Counters and distributions are cheap, they aggregate, and the poll rate is exactly what makes them useful: it is what lets you chart p95 check latency and see "database check went from 3ms to 400ms an hour before the outage".
latency_ms has been computed on every check since v0.1.0 and thrown
away into the response body. This is where it finally goes somewhere.
Sentry::Metrics is a SOFT dependency — guarded by defined?, never a
gemspec entry.
Instance Method Summary collapse
- #call(event_name, payload) ⇒ Object
-
#initialize(metric_prefix: "health") ⇒ Metrics
constructor
A new instance of Metrics.
Constructor Details
#initialize(metric_prefix: "health") ⇒ Metrics
Returns a new instance of Metrics.
19 20 21 |
# File 'lib/standard_health/notifiers/metrics.rb', line 19 def initialize(metric_prefix: "health") @prefix = metric_prefix end |
Instance Method Details
#call(event_name, payload) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/standard_health/notifiers/metrics.rb', line 23 def call(event_name, payload) return unless metrics_available? case event_name when "standard_health.check.completed" then record_check(payload) when "standard_health.ready.evaluated" then record_evaluation(payload) when "standard_health.check.timed_out" then record_timeout(payload) end rescue StandardError # Observability must never break the health path. nil end |