Class: Aws::Telemetry::OTelTracer
- Inherits:
-
TracerBase
- Object
- TracerBase
- Aws::Telemetry::OTelTracer
- Defined in:
- gems/aws-sdk-core/lib/aws-sdk-core/telemetry/otel.rb
Overview
OpenTelemetry-based TracerBase, responsible for creating spans.
Instance Method Summary collapse
-
#current_span ⇒ Aws::Telemetry::OTelSpan
Returns the current active span.
-
#in_span(name, attributes: nil, kind: nil, &block) ⇒ Aws::Telemetry::OTelSpan
A helper for the default use-case of extending the current trace with a span.
-
#initialize(tracer) ⇒ OTelTracer
constructor
A new instance of OTelTracer.
-
#start_span(name, with_parent: nil, attributes: nil, kind: nil) ⇒ Aws::Telemetry::OTelSpan
Used when a caller wants to manage the activation/deactivation and lifecycle of the Span and its parent manually.
Constructor Details
#initialize(tracer) ⇒ OTelTracer
Returns a new instance of OTelTracer.
81 82 83 84 |
# File 'gems/aws-sdk-core/lib/aws-sdk-core/telemetry/otel.rb', line 81 def initialize(tracer) super() @tracer = tracer end |
Instance Method Details
#current_span ⇒ Aws::Telemetry::OTelSpan
Returns the current active span.
123 124 125 |
# File 'gems/aws-sdk-core/lib/aws-sdk-core/telemetry/otel.rb', line 123 def current_span OTelSpan.new(OpenTelemetry::Trace.current_span) end |
#in_span(name, attributes: nil, kind: nil, &block) ⇒ Aws::Telemetry::OTelSpan
A helper for the default use-case of extending the current trace with a span. On exit, the Span that was active before calling this method will be reactivated. If an exception occurs during the execution of the provided block, it will be recorded on the span and re-raised.
114 115 116 117 118 |
# File 'gems/aws-sdk-core/lib/aws-sdk-core/telemetry/otel.rb', line 114 def in_span(name, attributes: nil, kind: nil, &block) @tracer.in_span(name, attributes: attributes, kind: kind) do |span| block.call(OTelSpan.new(span)) end end |
#start_span(name, with_parent: nil, attributes: nil, kind: nil) ⇒ Aws::Telemetry::OTelSpan
Used when a caller wants to manage the activation/deactivation and lifecycle of the Span and its parent manually.
94 95 96 97 98 99 100 101 102 |
# File 'gems/aws-sdk-core/lib/aws-sdk-core/telemetry/otel.rb', line 94 def start_span(name, with_parent: nil, attributes: nil, kind: nil) span = @tracer.start_span( name, with_parent: with_parent, attributes: attributes, kind: kind ) OTelSpan.new(span) end |