Class: Appsignal::Hooks::ActiveSupportNotificationsHook Private
- Defined in:
- lib/appsignal/hooks/active_support_notifications.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- BANG =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"!".freeze
Instance Method Summary collapse
- #dependencies_present? ⇒ Boolean private
- #install ⇒ Object private
Methods inherited from Hook
#initialize, #installed?, register, #try_to_install
Constructor Details
This class inherits a constructor from Appsignal::Hooks::Hook
Instance Method Details
#dependencies_present? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
11 12 13 |
# File 'lib/appsignal/hooks/active_support_notifications.rb', line 11 def dependencies_present? defined?(::ActiveSupport::Notifications::Instrumenter) end |
#install ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/appsignal/hooks/active_support_notifications.rb', line 15 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 |