Class: SignalFx::Lambda::Tracing::B3CodecCommon

Inherits:
Object
  • Object
show all
Defined in:
lib/signalfx/lambda/tracing/extractors.rb

Class Method Summary collapse

Class Method Details

.extract(carrier, keys) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/signalfx/lambda/tracing/extractors.rb', line 36

def self.extract(carrier, keys)
  trace_id = TraceId.base16_hex_id_to_uint64(carrier[keys::TRACE_ID])
  span_id = TraceId.base16_hex_id_to_uint64(carrier[keys::SPAN_ID])
  parent_id = TraceId.base16_hex_id_to_uint64(carrier[keys::PARENT_SPAN_ID])
  flags = parse_flags(carrier[keys::FLAGS], carrier[keys::SAMPLED])

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

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