Class: Jaeger::Extractors::SerializedJaegerTrace

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

Class Method Summary collapse

Class Method Details

.parse(trace) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/jaeger/extractors.rb', line 6

def self.parse(trace)
  return nil if !trace || trace == ''

  trace_arguments = trace.split(':')
  return nil if trace_arguments.size != 4

  trace_id = TraceId.base16_hex_id_to_uint128(trace_arguments[0])
  span_id, parent_id, flags = trace_arguments[1..3].map(&TraceId.method(:base16_hex_id_to_uint64))

  return nil if trace_id.zero? || span_id.zero?

  SpanContext.new(
    trace_id: trace_id,
    parent_id: parent_id,
    span_id: span_id,
    flags: flags
  )
end