Class: Atatus::TraceContext Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/atatus/trace_context.rb,
lib/atatus/trace_context/tracestate.rb,
lib/atatus/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, **legacy_traceparent_attrs) ⇒ 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
37
# File 'lib/atatus/trace_context.rb', line 30

def initialize(
  traceparent: nil,
  tracestate: nil,
  **legacy_traceparent_attrs
)
  @traceparent = traceparent || Traceparent.new(**legacy_traceparent_attrs)
  @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.



39
40
41
# File 'lib/atatus/trace_context.rb', line 39

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.



39
40
41
# File 'lib/atatus/trace_context.rb', line 39

def tracestate
  @tracestate
end

Class Method Details

.parse(legacy_header = nil, 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.

rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/atatus/trace_context.rb', line 46

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

  if legacy_header
    legacy_parse_from_header(legacy_header)
  elsif 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:



106
107
108
109
110
111
112
113
114
115
116
# File 'lib/atatus/trace_context.rb', line 106

def apply_headers
  yield 'Traceparent', traceparent.to_header

  if tracestate
    yield 'Tracestate', tracestate.to_header
  end

  return unless Atatus.agent.config.use_atatus_traceparent_header

  yield 'Atatus-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.



100
101
102
103
104
# File 'lib/atatus/trace_context.rb', line 100

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