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.
Instance Method Summary collapse
- #dependencies_present? ⇒ Boolean private
- #install ⇒ Object private
- #install_module(mod) ⇒ 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 |
# 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 require "appsignal/integrations/active_support_notifications" instrumenter = ::ActiveSupport::Notifications::Instrumenter parent_integration_module = Appsignal::Integrations::ActiveSupportNotificationsIntegration if instrumenter.method_defined?(:start) && instrumenter.method_defined?(:finish) install_module(parent_integration_module::StartFinishIntegration) else install_module(parent_integration_module::InstrumentIntegration) end # rubocop:disable Style/GuardClause if instrumenter.method_defined?(:finish_with_state) install_module(parent_integration_module::FinishStateIntegration) end end |
#install_module(mod) ⇒ 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.
39 40 41 |
# File 'lib/appsignal/hooks/active_support_notifications.rb', line 39 def install_module(mod) ::ActiveSupport::Notifications::Instrumenter.send(:prepend, mod) end |