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 42 43 44 45 46 47 48 49 |
# File 'lib/appsignal/hooks/active_support_notifications.rb', line 13 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.to_s, title, body, body_format ) end end end end |