Context
Follow-up from PR #64 (opt-in OpenTelemetry export). The trace exporter uses a ParentBased(TraceIdRatioBased) sampler, which honors a parent only if a parent span context is already on the current context. shunt does not yet extract an inbound W3C traceparent header from incoming requests, so every proxy_request span is currently a root — a client that propagates a trace (e.g. via traceparent) will not have its trace connected through the gateway.
Raised by cubic on PR #64 (src/telemetry.rs sampler).
Proposed work
- Install a global text-map propagator (
opentelemetry_sdk::propagation::TraceContextPropagator).
- In
src/proxy.rs, extract the parent Context from the request HeaderMap (e.g. opentelemetry_http::HeaderExtractor) and set it as the parent of the proxy_request span via tracing_opentelemetry::OpenTelemetrySpanExt::set_parent.
- Consider whether inbound trace ids should be trusted unconditionally at a gateway boundary, or gated (a client could inject arbitrary trace ids). Document the choice.
- Add a test covering extraction + parenting.
Out of scope for #64
#64 is the initial opt-in export surface; inbound propagation is a distinct enhancement with its own trust/security considerations, so it was deferred here (the misleading 'traceparent is honored' comment was corrected in #64).
Context
Follow-up from PR #64 (opt-in OpenTelemetry export). The trace exporter uses a
ParentBased(TraceIdRatioBased)sampler, which honors a parent only if a parent span context is already on the current context. shunt does not yet extract an inbound W3Ctraceparentheader from incoming requests, so everyproxy_requestspan is currently a root — a client that propagates a trace (e.g. viatraceparent) will not have its trace connected through the gateway.Raised by cubic on PR #64 (src/telemetry.rs sampler).
Proposed work
opentelemetry_sdk::propagation::TraceContextPropagator).src/proxy.rs, extract the parentContextfrom the requestHeaderMap(e.g.opentelemetry_http::HeaderExtractor) and set it as the parent of theproxy_requestspan viatracing_opentelemetry::OpenTelemetrySpanExt::set_parent.Out of scope for #64
#64 is the initial opt-in export surface; inbound propagation is a distinct enhancement with its own trust/security considerations, so it was deferred here (the misleading 'traceparent is honored' comment was corrected in #64).