Method: Honeycomb::W3CPropagation::UnmarshalTraceContext.parse

Defined in:
lib/honeycomb/propagation/w3c.rb

.parse(serialized_trace) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/honeycomb/propagation/w3c.rb', line 15

def parse(serialized_trace)
  unless serialized_trace.nil?
    version, payload = serialized_trace.split("-", 2)
    # version should be 2 hex characters
    if /^[A-Fa-f0-9]{2}$/.match?(version)
      trace_id, parent_span_id = parse_v1(payload)

      if !trace_id.nil? && !parent_span_id.nil?
        # return nil for dataset
        return [trace_id, parent_span_id, nil, nil]
      end
    end
  end
  [nil, nil, nil, nil]
end