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.
9 10 11 |
# File 'lib/appsignal/hooks/active_support_notifications.rb', line 9 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.
13 14 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 |
# File 'lib/appsignal/hooks/active_support_notifications.rb', line 13 def install ::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 return_value = instrument_without_appsignal(name, payload, &block) if instrument_this title, body, body_format = Appsignal::EventFormatter.format(name, payload) transaction.finish_event( name, title, body, body_format ) end return_value end end end |