Class: StandardHealth::Notifiers::Sentry

Inherits:
Object
  • Object
show all
Defined in:
lib/standard_health/notifiers/sentry.rb

Overview

Forwards readiness degradation to Sentry.

TRANSITION-ONLY, WITH A REPEAT FLOOR. This is the load-bearing difference from StandardCircuit's Sentry notifier, and it is not a style preference.

Circuit events are state transitions — rare, so capturing each one is fine. Health events are POLLS at ~6/minute/instance. Capturing each non-ok evaluation would turn a five-minute outage into ~30 duplicate Sentry events per instance, which is how alerting gets muted.

So we capture only when the status CHANGES, plus a floor (default 60s) that re-reports a sustained bad state occasionally rather than never. Recovery (back to :ok) is reported once, at :info, because "it came back" is genuinely useful and happens exactly once per incident.

State is per-process and mutex-guarded: Puma runs threaded, and several threads can serve concurrent probes.

Sentry is a SOFT dependency — guarded by defined?, never a gemspec entry — so hosts that don't use Sentry pay nothing.

Constant Summary collapse

DEFAULT_REPEAT_FLOOR_SECONDS =
60

Instance Method Summary collapse

Constructor Details

#initialize(repeat_floor_seconds: DEFAULT_REPEAT_FLOOR_SECONDS) ⇒ Sentry

Returns a new instance of Sentry.



28
29
30
31
32
33
34
# File 'lib/standard_health/notifiers/sentry.rb', line 28

def initialize(repeat_floor_seconds: DEFAULT_REPEAT_FLOOR_SECONDS)
  @repeat_floor_seconds = repeat_floor_seconds
  @mutex = Mutex.new
  @last_status = nil
  @last_reported_status = nil
  @last_reported_at = nil
end

Instance Method Details

#call(event_name, payload) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/standard_health/notifiers/sentry.rb', line 36

def call(event_name, payload)
  return unless event_name == "standard_health.ready.evaluated"
  return unless sentry_available?

  status = payload[:status]&.to_sym
  return if status.nil?

  return unless should_report?(status)

  capture(status, payload)
end