Sha256: 27798d0fa144103faf92e5b02b1957bd6f4303a3df7ef3e4143fc0061fed68d3
Contents?: true
Size: 1.48 KB
Versions: 4
Compression:
Stored size: 1.48 KB
Contents
module Appsignal class Hooks # @api private class ActiveSupportNotificationsHook < Appsignal::Hooks::Hook register :active_support_notifications BANG = "!".freeze def dependencies_present? defined?(::ActiveSupport::Notifications::Instrumenter) end 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 if instrument_this transaction = Appsignal::Transaction.current transaction.start_event end instrument_without_appsignal(name, payload, &block) ensure if instrument_this title, body, body_format = Appsignal::EventFormatter.format(name, payload) transaction.finish_event( name, title, body, body_format ) end end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems