Class: Datadog::Tracing::SpanOperation::Events::OnError
- Inherits:
-
Object
- Object
- Datadog::Tracing::SpanOperation::Events::OnError
- Defined in:
- lib/datadog/tracing/span_operation.rb
Overview
Triggered when the span raises an error during measurement.
Instance Method Summary collapse
-
#initialize(default) ⇒ OnError
constructor
A new instance of OnError.
- #publish(*args) ⇒ Object
-
#wrap_default ⇒ Object
DEV: Revisit this before full 1.0 release.
Constructor Details
#initialize(default) ⇒ OnError
Returns a new instance of OnError.
380 381 382 |
# File 'lib/datadog/tracing/span_operation.rb', line 380 def initialize(default) @handler = default end |
Instance Method Details
#publish(*args) ⇒ Object
407 408 409 410 411 412 413 414 415 416 417 |
# File 'lib/datadog/tracing/span_operation.rb', line 407 def publish(*args) begin @handler.call(*args) rescue StandardError => e Datadog.logger.debug do "Error in on_error handler '#{@default}': #{e.class.name} #{e.} at #{Array(e.backtrace).first}" end end true end |
#wrap_default ⇒ Object
DEV: Revisit this before full 1.0 release. It seems like OnError wants to behave like a middleware stack, where each “subscriber”‘s executed is chained to the previous one. This is different from how Event works, and might be incompatible.
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 |
# File 'lib/datadog/tracing/span_operation.rb', line 390 def wrap_default original = @handler @handler = proc do |op, error| begin yield(op, error) rescue StandardError => e Datadog.logger.debug do "Custom on_error handler #{@handler} failed, using fallback behavior. \ Cause: #{e.class.name} #{e.} Location: #{Array(e.backtrace).first}" end original.call(op, error) if original end end end |