Skip to main content

extract_parent_into_current_span

Function extract_parent_into_current_span 

Source
pub fn extract_parent_into_current_span(headers: &HeaderMap)
Expand description

Extract the parent OTel context from headers and attach it to the current tracing::Span, so server-side spans share the dialer’s trace id.

A missing or malformed traceparent produces an empty context, which set_parent accepts as a no-op — the local span just stays a root span.

Calling this from a #[tracing::instrument]’d handler must happen before the first call to tracing::Span::context on the same span (or anything that triggers a span entry that consults the parent), per tracing-opentelemetry’s ordering contract. The two server-side connect handlers wire it first thing in the function body for exactly this reason.