Function extract_context

Source
pub fn extract_context(headers: &HeaderMap) -> Context
Expand description

Extracts OpenTelemetry context from HTTP headers.

This function extracts trace context information from HTTP headers using the globally configured text map propagator. If no trace context is found in the headers, it returns an unsampled context.

§Arguments

  • headers: Reference to HTTP headers to extract context from

§Returns

An OpenTelemetry Context containing the extracted trace information, or an unsampled context if no trace data was found.

§Examples

use http::HeaderMap;
use telemetry_rust::http::extract_context;

let headers = HeaderMap::new();
let context = extract_context(&headers);