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 Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize(default, logger: Datadog.logger) ⇒ OnError
constructor
A new instance of OnError.
- #publish(*args) ⇒ Object
-
#wrap_default ⇒ Object
DEV: Revisit this before full 1.0 release.
Constructor Details
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
459 460 461 |
# File 'lib/datadog/tracing/span_operation.rb', line 459 def logger @logger end |
Instance Method Details
#publish(*args) ⇒ Object
482 483 484 485 486 487 488 489 490 491 492 |
# File 'lib/datadog/tracing/span_operation.rb', line 482 def publish(*args) begin @handler.call(*args) rescue => e logger.debug do "Error in on_error handler '#{@handler}': #{e.class}: #{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.
467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
# File 'lib/datadog/tracing/span_operation.rb', line 467 def wrap_default original = @handler @handler = proc do |op, error| yield(op, error) rescue => e logger.debug do "Custom on_error handler #{@handler} failed, using fallback behavior. \ Cause: #{e.class}: #{e.} Location: #{Array(e.backtrace).first}" end original&.call(op, error) end end |