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.
391 392 393 |
# File 'lib/datadog/tracing/span_operation.rb', line 391 def initialize(default) @handler = default end |
Instance Method Details
#publish(*args) ⇒ Object
418 419 420 421 422 423 424 425 426 427 428 |
# File 'lib/datadog/tracing/span_operation.rb', line 418 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.
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
# File 'lib/datadog/tracing/span_operation.rb', line 401 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 |