Skip to main content

Module propagation

Module propagation 

Source
Expand description

W3C traceparent propagation across the connectrpc boundary.

Pairs with crate::observability::init (which installs the global TraceContextPropagator). Together they close the OTel cross-process story: a turn started on the control plane carries its trace context into the harness’s connect span, so a single user request stitches into one trace tree across the control-plane → harness hop.

§Direction

  • Outgoing: inject_current_span_into writes the current tracing::Span’s OTel context into an http::HeaderMap using the globally-installed propagator. Callers attach the headers to a connectrpc::client::CallOptions (per-call) or connectrpc::client::ClientConfig (per-client default).
  • Incoming: extract_parent_into_current_span reads traceparent (and any other propagator-registered fields) off a borrowed http::HeaderMap and re-parents the current tracing::Span so the server-side span shares the dialer’s trace id.

§Design

The Injector/Extractor adapters are intentionally trivial — they exist because opentelemetry’s trait surface is carrier-agnostic and http::HeaderMap is not. Keeping them in polyc-runtime means the control plane, the harness, and any future server share one implementation; per-call sites only pick which side (inject vs extract) they need.

Structs§

HttpHeaderExtractor
Adapter that lets the global OTel propagator read traceparent (and any other fields) off an http::HeaderMap.
HttpHeaderInjector
Adapter that injects propagator fields into an http::HeaderMap.

Functions§

extract_context_from
Extract a parent Context from headers using the globally-installed propagator. Lower-level than extract_parent_into_current_span.
extract_parent_into_current_span
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.
inject_context_into
Inject a specific Context into headers. Lower-level than inject_current_span_into; prefer that for production call sites.
inject_current_span_into
Inject the current tracing::Span’s OTel context into headers.