Class: ElasticAPM::OpenTracing::SpanContext Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/elastic_apm/opentracing.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(trace_context:, baggage: nil) ⇒ SpanContext

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of SpanContext.



115
116
117
118
119
120
121
122
123
# File 'lib/elastic_apm/opentracing.rb', line 115

def initialize(trace_context:, baggage: nil)
  if baggage
    ElasticAPM.agent.config.logger.warn(
      'Baggage is not supported by ElasticAPM'
    )
  end

  @trace_context = trace_context
end

Instance Attribute Details

#trace_contextObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



125
126
127
# File 'lib/elastic_apm/opentracing.rb', line 125

def trace_context
  @trace_context
end

Class Method Details

.from_header(header) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/elastic_apm/opentracing.rb', line 129

def self.from_header(header)
  return unless header

  trace_context = TraceContext.new(
    traceparent: TraceContext::Traceparent.parse(header)
  )

  trace_context.traceparent.id = trace_context.parent_id
  trace_context.traceparent.parent_id = nil

  from_trace_context(trace_context)
end

.from_trace_context(trace_context) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



142
143
144
# File 'lib/elastic_apm/opentracing.rb', line 142

def self.from_trace_context(trace_context)
  new(trace_context: trace_context)
end

Instance Method Details

#childObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



146
147
148
# File 'lib/elastic_apm/opentracing.rb', line 146

def child
  self.class.from_trace_context(trace_context.child)
end