Class: StandardCircuit::Notifiers::Sentry
- Inherits:
-
Object
- Object
- StandardCircuit::Notifiers::Sentry
- Defined in:
- lib/standard_circuit/notifiers/sentry.rb
Overview
Subscribes to standard_circuit.circuit.opened and forwards a message to Sentry. Other transitions are ignored — only RED matters for alerting.
Two reporting shapes:
- Flat (default, and the only 0.2.x behaviour): every circuit reports
at
:warningwith the circuit's colors and error inextra. No tags, no fingerprint. - Criticality-aware (opt in via
config.sentry_criticality_levels): the level is chosen from the circuit's registered criticality, and the report gainscircuit/circuit_criticalitytags plus a stable["circuit-open", circuit]fingerprint so Sentry alert rules can route and group by circuit.
Flat stays the default deliberately. Both the level and the fingerprint feed Sentry's alerting and grouping, so a gem bump must not silently re-page or re-group a host app's existing issues — see CHANGELOG.
Constant Summary collapse
- OPENED_EVENT =
"standard_circuit.circuit.opened".freeze
- DEFAULT_LEVEL =
Level used in flat mode, and the fallback for an unrecognised criticality in criticality-aware mode.
:warning- DEFAULT_LEVELS =
The recommended criticality -> Sentry level mapping, used when
config.sentry_criticality_levels = true. :critical is loud enough to page; :optional stays informational so a flapping nice-to-have upstream doesn't cry wolf. { critical: :error, standard: :warning, optional: :info }.freeze
Instance Method Summary collapse
- #call(event_name, payload) ⇒ Object
-
#initialize(levels: nil) ⇒ Sentry
constructor
A new instance of Sentry.
Constructor Details
#initialize(levels: nil) ⇒ Sentry
Returns a new instance of Sentry.
39 40 41 |
# File 'lib/standard_circuit/notifiers/sentry.rb', line 39 def initialize(levels: nil) @levels = levels end |
Instance Method Details
#call(event_name, payload) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/standard_circuit/notifiers/sentry.rb', line 43 def call(event_name, payload) return unless event_name == OPENED_EVENT return unless defined?(::Sentry) && ::Sentry.respond_to?(:capture_message) @levels ? capture_criticality_aware(payload) : capture_flat(payload) end |