Class: StandardCircuit::Notifiers::Sentry

Inherits:
Object
  • Object
show all
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 :warning with the circuit's colors and error in extra. 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 gains circuit / circuit_criticality tags 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

Constructor Details

#initialize(levels: nil) ⇒ Sentry

Returns a new instance of Sentry.

Parameters:

  • levels (Hash{Symbol=>Symbol}, nil) (defaults to: nil)

    criticality -> level map. nil (the default) selects flat :warning reporting.



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