Class: Jaeger::Extractors::JaegerRackCodec

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

Class Method Summary collapse

Class Method Details

.extract(carrier) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/jaeger/extractors.rb', line 43

def self.extract(carrier)
  serialized_trace = carrier['HTTP_UBER_TRACE_ID']
  serialized_trace = CGI.unescape(serialized_trace) if serialized_trace
  context = SerializedJaegerTrace.parse(serialized_trace)
  return nil unless context

  carrier.each do |key, value|
    baggage_match = key.match(/\AHTTP_UBERCTX_(\w+)\Z/)
    if baggage_match
      key = baggage_match[1].downcase.tr('_', '-')
      context.set_baggage_item(key, CGI.unescape(value))
    end
  end

  context
end