fix(tracing-actix-web): populate trace_id at span creation#724
Merged
JohnTitor merged 2 commits intoactix:mainfrom May 1, 2026
Merged
fix(tracing-actix-web): populate trace_id at span creation#724JohnTitor merged 2 commits intoactix:mainfrom
JohnTitor merged 2 commits intoactix:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
Bug Fix
PR Checklist
cargo +nightly fmt).Overview
When a request arrives with a
traceparentheader, thetrace_idwas missing from the "REQUEST START" log entry and only appeared at "REQUEST END". The cause:trace_idwas set viaspan.record()after the span had already been created, but subscribers liketracing-bunyan-formatteremit START duringon_new_span— at which point the field is stillEmpty.This PR extracts the
trace_idfrom the propagated context before creating the span, so it is baked into the span fields from the start. When there is no remote parent (notraceparentheader), the field staysEmptyand gets filled later byset_otel_parentexactly as before — no behavior change in that path.What changed
tracing-actix-web/src/otel.rs— newextract_trace_id()that pulls the trace_id from request headers via the global propagator.tracing-actix-web/src/root_span_macro.rs—root_span!now callsextract_otel_trace_id()before span creation; twoinner_spanarms handle the "known trace_id" vs "empty" cases (unavoidable sincetracing::Valueis sealed).No breaking changes.
Original PR was at the old repo: LukeMathWalker/tracing-actix-web#145