Class: StandardCircuit::Notifiers::Sentry

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

Instance Method Summary collapse

Instance Method Details

#notify(light, from_color, to_color, error) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/standard_circuit/notifiers/sentry.rb', line 4

def notify(light, from_color, to_color, error)
  return unless to_color == Stoplight::Color::RED
  return unless defined?(::Sentry) && ::Sentry.respond_to?(:capture_message)

  message = "Circuit breaker opened: #{light.name}"
  ::Sentry.capture_message(
    message,
    level: :warning,
    extra: {
      circuit: light.name,
      from_color: from_color,
      to_color: to_color,
      error_class: error&.class&.name,
      error_message: error&.message
    }.compact
  )
  message
end