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