Module: Datadog::OpenTracer::RackPropagator
- Extended by:
- Propagator
- Defined in:
- lib/datadog/opentracer/rack_propagator.rb
Overview
OpenTracing propagator for Datadog::OpenTracer::Tracer
Constant Summary collapse
- BAGGAGE_PREFIX =
'ot-baggage-'.freeze
- BAGGAGE_PREFIX_FORMATTED =
'HTTP_OT_BAGGAGE_'.freeze
Class Method Summary collapse
-
.extract(carrier) ⇒ SpanContext?
Extract a SpanContext in Rack format from the given carrier.
-
.inject(span_context, carrier) ⇒ Object
Inject a SpanContext into the given carrier.
Methods included from Propagator
Class Method Details
.extract(carrier) ⇒ SpanContext?
Extract a SpanContext in Rack format from the given carrier.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/datadog/opentracer/rack_propagator.rb', line 42 def extract(carrier) # First extract & build a Datadog context datadog_trace_digest = Tracing::Propagation::HTTP.extract(carrier) # Then extract any other baggage baggage = {} carrier.each do |key, value| baggage[header_to_baggage(key)] = value if baggage_header?(key) end SpanContextFactory.build( datadog_context: nil, datadog_trace_digest: datadog_trace_digest, baggage: baggage ) end |
.inject(span_context, carrier) ⇒ Object
Inject a SpanContext into the given carrier
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/datadog/opentracer/rack_propagator.rb', line 20 def inject(span_context, carrier) digest = if span_context.datadog_context && span_context.datadog_context.active_trace span_context.datadog_context.active_trace.to_digest else span_context.datadog_trace_digest end # Inject Datadog trace properties Tracing::Propagation::HTTP.inject!(digest, carrier) # Inject baggage span_context.baggage.each do |key, value| carrier[BAGGAGE_PREFIX + key] = value end nil end |