Class: Jaeger::Injectors::TraceContextRackCodec

Inherits:
Object
  • Object
show all
Defined in:
lib/jaeger/injectors.rb

Class Method Summary collapse

Class Method Details

.inject(span_context, carrier) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/jaeger/injectors.rb', line 55

def self.inject(span_context, carrier)
  flags = span_context.sampled? || span_context.debug? ? 1 : 0

  carrier['traceparent'] = format(
    '%<version>s-%<trace_id>s-%<span_id>s-%<flags>s',
    version: '00',
    trace_id: span_context.trace_id.to_s(16).rjust(32, '0'),
    span_id: span_context.span_id.to_s(16).rjust(16, '0'),
    flags: flags.to_s(16).rjust(2, '0')
  )
end