trace: preserve parent context in no-op tracer - #8989
Open
sb123sb123 wants to merge 2 commits into
Open
sb123sb123 wants to merge 2 commits into
sb123sb123 wants to merge 2 commits into
Conversation
Signed-off-by: sb123sb123 <152394158+sb123sb123@users.noreply.github.com>
sb123sb123
requested review from
MrAlias,
XSAM,
dashpole,
dmathieu,
flc1125 and
pellared
as code owners
September 21, 2026 16:13
|
Signed-off-by: sb123sb123 <152394158+sb123sb123@users.noreply.github.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 #4027
Cause
The deprecated
go.opentelemetry.io/otel/trace.NewNoopTracerProvideronly preserved its ownnonRecordingSpanwrapper. When a recording parent span was present in the context, it replaced that span with an empty no-op span and dropped the parent trace ID.Fix
Preserve any existing non-recording span. For a recording parent, create a non-recording span carrying the parent's
SpanContext, so no-op instrumentation does not turn a valid trace into a new root.Tests
TestNoopTracerStartPreservesRecordingParent.go test -run '^TestNoopTracerStartPreservesRecordingParent$' -count=1 .(pass)go test -count=20 -run '^TestNoopTracerStartPreservesRecordingParent$' .(pass)go test ./...from thetraceworkspace (pass)go vet ./...from thetraceworkspace (pass)gofmt -d trace/noop.go trace/noop_test.goandgit diff --check(pass)/g/OSS-PR-200/work/golangci-lint-6807.exe run --fast-only --timeout 60s --allow-serial-runnersfrom thetraceworkspace (pass; 0 issues)7430d856c5cb42acf07385036965189ae18d70ab.Limitations
make precommitcould not run becausemakeis unavailable on the Windows host.github.com/go-logr/logr@v1.4.4could not be downloaded because the host's proxy/GitHub network was intermittent; the completetraceworkspace passed.go test -racecould not run: the Windows host requires CGO for race mode, and its available clang rejects the required-mthreadstarget option.No generated files or dependencies were changed.
AI assistance
This PR was prepared with AI assistance by OpenAI Codex under autonomous user direction. The agent performed and reviewed the repository research, implementation, regression test, and verification; the change is intentionally limited to the bug fix, deterministic test, and required changelog entry.