Class: OpenTelemetry::Trace::Link

Inherits:
Object
  • Object
show all
Defined in:
lib/opentelemetry/trace/link.rb

Overview

A link to a Span. Used (for example) in batching operations, where a single batch handler processes multiple requests from different traces. A Link can be also used to reference spans from the same trace. A Link and its attributes are immutable.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(span_context, attributes = nil) ⇒ Link

Returns a new immutable OpenTelemetry::Trace::Link.

Parameters:

  • span_context (SpanContext)

    The context of the linked Span.

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

    A hash of attributes for this link. Attributes will be frozen during Link initialization.



35
36
37
38
# File 'lib/opentelemetry/trace/link.rb', line 35

def initialize(span_context, attributes = nil)
  @span_context = span_context
  @attributes = attributes.freeze || EMPTY_ATTRIBUTES
end

Instance Attribute Details

#attributesHash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>} (readonly)

Returns the frozen attributes for this link.

Returns:

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


26
27
28
# File 'lib/opentelemetry/trace/link.rb', line 26

def attributes
  @attributes
end

#span_contextSpanContext (readonly)

Returns the SpanContext for this link

Returns:



21
22
23
# File 'lib/opentelemetry/trace/link.rb', line 21

def span_context
  @span_context
end

Instance Method Details

#==(other) ⇒ Object

Returns true if two OpenTelemetry::Trace::Links are equal.



41
42
43
# File 'lib/opentelemetry/trace/link.rb', line 41

def ==(other)
  other.span_context == @span_context && other.attributes == @attributes
end