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.
137 138 139 |
# File 'lib/datadog/tracing/contrib/active_support/notifications/subscription.rb', line 137 def initialize @blocks = {} end |
Instance Attribute Details
#blocks ⇒ Object (readonly)
Returns the value of attribute blocks.
135 136 137 |
# File 'lib/datadog/tracing/contrib/active_support/notifications/subscription.rb', line 135 def blocks @blocks end |
Instance Method Details
#add(key, &block) ⇒ Object
141 142 143 |
# File 'lib/datadog/tracing/contrib/active_support/notifications/subscription.rb', line 141 def add(key, &block) blocks_for(key) << block if block end |
#run(event, key, *args) ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/datadog/tracing/contrib/active_support/notifications/subscription.rb', line 145 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 |