Preserve random trace ID flag for child spans#5241
Merged
xrmx merged 3 commits intoMay 21, 2026
Merged
Conversation
Assisted-by: OpenAI Codex
Assisted-by: OpenAI Codex
xrmx
approved these changes
May 21, 2026
herin049
approved these changes
May 21, 2026
xrmx
reviewed
May 21, 2026
Assisted-by: OpenAI Codex
xrmx
pushed a commit
that referenced
this pull request
May 21, 2026
* fix: preserve random trace flag for child spans Assisted-by: OpenAI Codex * chore: add changelog for random trace flag fix Assisted-by: OpenAI Codex * chore: clarify random trace flag changelog Assisted-by: OpenAI Codex Co-authored-by: Tasdiqul Islam <tasdiq088@gmail.com>
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.
Fixes #5240
Summary
random-trace-idflag from the configured ID generator only when this tracer generates a new root trace ID.random-trace-idbit when creating child spans that continue an existing trace ID.Why
The 1.42.0 random trace ID support consults the ID generator for every new span. That makes child spans advertise
RANDOM_TRACE_IDeven when they continue a trace ID inherited from an incoming parent that did not set the bit.Testing
0x01changed from child flags0x03to child flags0x01python3 -m pytest opentelemetry-sdk/tests/trace/test_trace.py::TestSpanCreation::test_start_span_preserves_parent_random_trace_id_flag- passedpython3 -m pytest opentelemetry-sdk/tests/trace/test_trace.py::TestSpanCreation::test_start_span_implicit opentelemetry-sdk/tests/trace/test_trace.py::TestSpanCreation::test_start_span_explicit opentelemetry-sdk/tests/trace/test_trace.py::TestSpanCreation::test_start_span_preserves_parent_random_trace_id_flag- passedpython3 -m ruff check opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py opentelemetry-sdk/tests/trace/test_trace.py- passedpython3 -m py_compile opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py opentelemetry-sdk/tests/trace/test_trace.py- passedNotes
python3 -m pytest opentelemetry-sdk/tests/trace/test_trace.pyran107 passedand failed onlyTestTracer.test_shutdownin this shell becauseshutil.which("python")returnedNone; this environment haspython3but nopythonexecutable onPATH.SelectableGroupswarning tracked by Importing opentelemetry.context issues a warning in Python 3.10 and 3.11 #5231.