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
#initialize(default, logger: Datadog.logger) ⇒ OnError
Returns a new instance of OnError.
441 442 443 444 |
# File 'lib/datadog/tracing/span_operation.rb', line 441 def initialize(default, logger: Datadog.logger) @handler = default @logger = logger end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
446 447 448 |
# File 'lib/datadog/tracing/span_operation.rb', line 446 def logger @logger end |
Instance Method Details
#publish(*args) ⇒ Object
469 470 471 472 473 474 475 476 477 478 479 |
# File 'lib/datadog/tracing/span_operation.rb', line 469 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.
454 455 456 457 458 459 460 461 462 463 464 465 466 467 |
# File 'lib/datadog/tracing/span_operation.rb', line 454 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 |