Class: Datadog::Tracing::Contrib::ActiveSupport::Notifications::Subscription::Callbacks
- Inherits:
-
Object
- Object
- Datadog::Tracing::Contrib::ActiveSupport::Notifications::Subscription::Callbacks
- Defined in:
- lib/datadog/tracing/contrib/active_support/notifications/subscription.rb
Overview
Wrapper for subscription callbacks
Instance Attribute Summary collapse
-
#blocks ⇒ Object
readonly
Returns the value of attribute blocks.
Instance Method Summary collapse
- #add(key, &block) ⇒ Object
-
#initialize ⇒ Callbacks
constructor
A new instance of Callbacks.
- #run(event, key, *args) ⇒ Object
Constructor Details
#initialize ⇒ Callbacks
Returns a new instance of Callbacks.
131 132 133 |
# File 'lib/datadog/tracing/contrib/active_support/notifications/subscription.rb', line 131 def initialize @blocks = {} end |
Instance Attribute Details
#blocks ⇒ Object (readonly)
Returns the value of attribute blocks.
129 130 131 |
# File 'lib/datadog/tracing/contrib/active_support/notifications/subscription.rb', line 129 def blocks @blocks end |
Instance Method Details
#add(key, &block) ⇒ Object
135 136 137 |
# File 'lib/datadog/tracing/contrib/active_support/notifications/subscription.rb', line 135 def add(key, &block) blocks_for(key) << block if block end |
#run(event, key, *args) ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/datadog/tracing/contrib/active_support/notifications/subscription.rb', line 139 def run(event, key, *args) blocks_for(key).each do |callback| begin callback.call(event, key, *args) rescue StandardError => e Datadog.logger.debug( "ActiveSupport::Notifications '#{key}' callback for '#{event}' failed: #{e.class.name} #{e.}" ) end end end |