Module: Appsignal::Integrations::ActiveSupportNotificationsIntegration::InstrumentIntegration

Defined in:
lib/appsignal/integrations/active_support_notifications.rb

Instance Method Summary collapse

Instance Method Details

#instrument(name, payload = {}, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/appsignal/integrations/active_support_notifications.rb', line 9

def instrument(name, payload = {}, &block)
  # Events that start with a bang are internal to Rails
  instrument_this = name[0] != ActiveSupportNotificationsIntegration::BANG

  Appsignal::Transaction.current.start_event if instrument_this

  super
ensure
  if instrument_this
    title, body, body_format = Appsignal::EventFormatter.format(name, payload)
    Appsignal::Transaction.current.finish_event(
      name.to_s,
      title,
      body,
      body_format
    )
  end
end