Class: OpenTelemetry::Baggage::Propagation::TextMapInjector
- Inherits:
-
Object
- Object
- OpenTelemetry::Baggage::Propagation::TextMapInjector
- Includes:
- Context::Propagation::DefaultSetter
- Defined in:
- lib/opentelemetry/baggage/propagation/text_map_injector.rb
Overview
Injects baggage using the W3C Baggage format
Instance Method Summary collapse
-
#initialize(baggage_key: 'baggage') ⇒ TextMapInjector
constructor
Returns a new TextMapInjector that injects context using the specified header key.
-
#inject(carrier, context) {|Carrier, String| ... } ⇒ Object
Inject in-process baggage into the supplied carrier.
Methods included from Context::Propagation::DefaultSetter
Constructor Details
#initialize(baggage_key: 'baggage') ⇒ TextMapInjector
Returns a new TextMapInjector that injects context using the specified header key
22 23 24 |
# File 'lib/opentelemetry/baggage/propagation/text_map_injector.rb', line 22 def initialize(baggage_key: 'baggage') @baggage_key = baggage_key end |
Instance Method Details
#inject(carrier, context) {|Carrier, String| ... } ⇒ Object
Inject in-process baggage into the supplied carrier.
36 37 38 39 40 41 42 43 |
# File 'lib/opentelemetry/baggage/propagation/text_map_injector.rb', line 36 def inject(carrier, context, &setter) return carrier unless (baggage = context[ContextKeys.baggage_key]) && !baggage.empty? setter ||= default_setter setter.call(carrier, @baggage_key, encode(baggage)) carrier end |