Class: OpenTelemetry::Propagator::B3::Multi::TextMapPropagator
- Inherits:
-
Object
- Object
- OpenTelemetry::Propagator::B3::Multi::TextMapPropagator
- Includes:
- TextMapExtractor
- Defined in:
- lib/opentelemetry/propagator/b3/multi/text_map_propagator.rb
Overview
Propagates trace context using the B3 multi header format
Instance Method Summary collapse
-
#fields ⇒ Array<String>
Returns the predefined propagation fields.
-
#inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter) ⇒ Object
Inject trace context into the supplied carrier.
Methods included from TextMapExtractor
Instance Method Details
#fields ⇒ Array<String>
Returns the predefined propagation fields. If your carrier is reused, you should delete the fields returned by this method before calling inject
.
57 58 59 |
# File 'lib/opentelemetry/propagator/b3/multi/text_map_propagator.rb', line 57 def fields FIELDS end |
#inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter) ⇒ Object
Inject trace context into the supplied carrier.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/opentelemetry/propagator/b3/multi/text_map_propagator.rb', line 35 def inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter) span_context = Trace.current_span(context).context return unless span_context.valid? setter.set(carrier, B3_TRACE_ID_KEY, span_context.hex_trace_id) setter.set(carrier, B3_SPAN_ID_KEY, span_context.hex_span_id) if B3.debug?(context) setter.set(carrier, B3_FLAGS_KEY, '1') elsif span_context.trace_flags.sampled? setter.set(carrier, B3_SAMPLED_KEY, '1') else setter.set(carrier, B3_SAMPLED_KEY, '0') end nil end |