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, Object>) (defaults to: nil)

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



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

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

Instance Attribute Details

#attributesHash<String, Object> (readonly)

Returns the frozen attributes for this link.

Returns:

  • (Hash<String, Object>)


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

def attributes
  @attributes
end

#contextSpanContext (readonly)

Returns the SpanContext for this link

Returns:



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

def context
  @context
end

Instance Method Details

#==(other) ⇒ Object

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



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

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