class Appsignal::Hooks::ActiveSupportNotificationsHook
@api private
def self.instrument(name, payload = {})
def self.instrument(name, payload = {}) # Don't check the notifier if any subscriber is listening: # AppSignal is listening instrumenter.instrument(name, payload) do yield payload if block_given? end end
def dependencies_present?
def dependencies_present? defined?(::ActiveSupport::Notifications::Instrumenter) end
def install
def install ::ActiveSupport::Notifications.class_eval do def self.instrument(name, payload = {}) # Don't check the notifier if any subscriber is listening: # AppSignal is listening instrumenter.instrument(name, payload) do yield payload if block_given? end end end ::ActiveSupport::Notifications::Instrumenter.class_eval do alias instrument_without_appsignal instrument def instrument(name, payload = {}, &block) # Events that start with a bang are internal to Rails instrument_this = name[0] != BANG Appsignal::Transaction.current.start_event if instrument_this instrument_without_appsignal(name, payload, &block) 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 end end
def instrument(name, payload = {}, &block)
def instrument(name, payload = {}, &block) # Events that start with a bang are internal to Rails instrument_this = name[0] != BANG Appsignal::Transaction.current.start_event if instrument_this instrument_without_appsignal(name, payload, &block) 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