Function inject_context_on_context

Source
pub fn inject_context_on_context(context: &Context, headers: &mut HeaderMap)
Expand description

Injects OpenTelemetry context from a specific context into HTTP headers.

This function takes an existing OpenTelemetry context and injects its trace information into the provided HTTP headers using the globally configured text map propagator.

§Arguments

  • context: The OpenTelemetry context to inject
  • headers: Mutable reference to HTTP headers where context will be injected

§Examples

use http::HeaderMap;
use opentelemetry::Context;
use telemetry_rust::http::inject_context_on_context;

let context = Context::current();
let mut headers = HeaderMap::new();
inject_context_on_context(&context, &mut headers);