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.
439 440 441 |
# File 'lib/datadog/tracing/span_operation.rb', line 439 def logger @logger end |
Instance Method Details
#publish(*args) ⇒ Object
462 463 464 465 466 467 468 469 470 471 472 |
# File 'lib/datadog/tracing/span_operation.rb', line 462 def publish(*args) begin @handler.call(*args) rescue => e logger.debug do "Error in on_error handler '#{@default}': #{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.
447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
# File 'lib/datadog/tracing/span_operation.rb', line 447 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 |