Class: ElasticAPM::TraceContext Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/elastic_apm/trace_context.rb,
lib/elastic_apm/trace_context/tracestate.rb,
lib/elastic_apm/trace_context/traceparent.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.

Defined Under Namespace

Classes: InvalidTraceparentHeader, Traceparent, Tracestate

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(traceparent: nil, tracestate: nil) ⇒ TraceContext

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 TraceContext.



30
31
32
33
34
35
36
# File 'lib/elastic_apm/trace_context.rb', line 30

def initialize(
  traceparent: nil,
  tracestate: nil
)
  @traceparent = traceparent || Traceparent.new
  @tracestate = tracestate || Tracestate.new
end

Instance Attribute Details

#traceparentObject

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.



38
39
40
# File 'lib/elastic_apm/trace_context.rb', line 38

def traceparent
  @traceparent
end

#tracestateObject

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.



38
39
40
# File 'lib/elastic_apm/trace_context.rb', line 38

def tracestate
  @tracestate
end

Class Method Details

.parse(env: nil, metadata: nil) ⇒ 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.



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/elastic_apm/trace_context.rb', line 44

def parse(env: nil, metadata: nil)
  unless env || 
    raise ArgumentError, 'TraceContext expects env:, metadata: ' \
      'or single argument header string'
  end

  if env
    trace_context_from_env(env)
  elsif 
    ()
  end
end

Instance Method Details

#apply_headers {|'Traceparent', traceparent.to_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.

Yields:



96
97
98
99
100
101
102
103
104
105
106
# File 'lib/elastic_apm/trace_context.rb', line 96

def apply_headers
  yield 'Traceparent', traceparent.to_header

  if tracestate && !tracestate.to_header.empty?
    yield 'Tracestate', tracestate.to_header
  end

  return unless ElasticAPM.agent.config.use_elastic_traceparent_header

  yield 'Elastic-Apm-Traceparent', traceparent.to_header
end

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



90
91
92
93
94
# File 'lib/elastic_apm/trace_context.rb', line 90

def child
  dup.tap do |tc|
    tc.traceparent = tc.traceparent.child
  end
end