Class: Aws::Telemetry::OTelSpan

Inherits:
SpanBase
  • Object
show all
Defined in:
lib/aws-sdk-core/telemetry/otel.rb

Overview

OpenTelemetry-based SpanBase, represents a single operation within a trace.

Instance Method Summary collapse

Constructor Details

#initialize(span) ⇒ OTelSpan

Returns a new instance of OTelSpan.



131
132
133
134
# File 'lib/aws-sdk-core/telemetry/otel.rb', line 131

def initialize(span)
  super()
  @span = span
end

Instance Method Details

#add_attributes(attributes) ⇒ self

Add attributes.

Parameters:

  • attributes (Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>})

    Values must be non-nil and (array of) string, boolean or numeric type. Array values must not contain nil elements and all elements must be of the same basic type (string, numeric, boolean)

Returns:

  • (self)

    returns itself



157
158
159
# File 'lib/aws-sdk-core/telemetry/otel.rb', line 157

def add_attributes(attributes)
  @span.add_attributes(attributes)
end

#add_event(name, attributes: nil) ⇒ self

Add event to a Span.

Parameters:

  • name (String)

    Name of the event

  • attributes (Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}) (defaults to: nil)

    Values must be non-nil and (array of) string, boolean or numeric type. Array values must not contain nil elements and all elements must be of the same basic type (string, numeric, boolean)

Returns:

  • (self)

    returns itself



170
171
172
# File 'lib/aws-sdk-core/telemetry/otel.rb', line 170

def add_event(name, attributes: nil)
  @span.add_event(name, attributes: attributes)
end

#finish(end_timestamp: nil) ⇒ self

Finishes the Span.

Parameters:

  • end_timestamp (Time) (defaults to: nil)

    End timestamp for the span

Returns:

  • (self)

    returns itself



187
188
189
# File 'lib/aws-sdk-core/telemetry/otel.rb', line 187

def finish(end_timestamp: nil)
  @span.finish(end_timestamp: end_timestamp)
end

#record_exception(exception, attributes: nil) ⇒ void

This method returns an undefined value.

Record an exception during the execution of this span. Multiple exceptions can be recorded on a span.

Parameters:

  • exception (Exception)

    The exception to be recorded

  • attributes (Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}) (defaults to: nil)

    One or more key:value pairs, where the keys must be strings and the values may be (array of) string, boolean or numeric type



200
201
202
# File 'lib/aws-sdk-core/telemetry/otel.rb', line 200

def record_exception(exception, attributes: nil)
  @span.record_exception(exception, attributes: attributes)
end

#set_attribute(key, value) ⇒ self Also known as: []=

Set attribute.

Parameters:

  • key (String)
  • value (String, Boolean, Numeric, Array<String, Numeric, Boolean>)

    Value must be non-nil and (array of) string, boolean or numeric type. Array values must not contain nil elements and all elements must be of the same basic type (string, numeric, boolean)

Returns:

  • (self)

    returns itself



144
145
146
# File 'lib/aws-sdk-core/telemetry/otel.rb', line 144

def set_attribute(key, value)
  @span.set_attribute(key, value)
end

#status=(status) ⇒ void

This method returns an undefined value.

Sets the Span status.

Parameters:

  • status (Aws::Telemetry::Status)

    The new status, which overrides the default Span status, which is ‘OK`



179
180
181
# File 'lib/aws-sdk-core/telemetry/otel.rb', line 179

def status=(status)
  @span.status = status
end