class Aws::Telemetry::OTelTracer

OpenTelemetry-based {TracerBase}, responsible for creating spans.

Public Class Methods

new(tracer) click to toggle source
Calls superclass method
# File lib/aws-sdk-core/telemetry/otel.rb, line 81
def initialize(tracer)
  super()
  @tracer = tracer
end

Public Instance Methods

current_span() click to toggle source

Returns the current active span.

@return [Aws::Telemetry::OTelSpan]

# File 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) click to toggle source

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.

@param [String] name Span name @param [Hash] attributes Attributes to attach to the span @param [Aws::Telemetry::SpanKind] kind Type of Span @return [Aws::Telemetry::OTelSpan]

# File 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) click to toggle source

Used when a caller wants to manage the activation/deactivation and lifecycle of the Span and its parent manually.

@param [String] name Span name @param [Object] with_parent Parent Context @param [Hash] attributes Attributes to attach to the span @param [Aws::Telemetry::SpanKind] kind Type of Span @return [Aws::Telemetry::OTelSpan]

# File 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