Skip to content

trace: preserve parent context in no-op tracer - #8989

Open
sb123sb123 wants to merge 2 commits into
open-telemetry:mainfrom
sb123sb123:fix/4027-noop-parent-context
Open

sb123sb123 wants to merge 2 commits into
open-telemetry:mainfrom
sb123sb123:fix/4027-noop-parent-context

Conversation

@sb123sb123

@sb123sb123 sb123sb123 commented Sep 21, 2026 •

Copy link
Copy Markdown

Fixes #4027

Cause

The deprecated go.opentelemetry.io/otel/trace.NewNoopTracerProvider only preserved its own nonRecordingSpan wrapper. 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

  • Added TestNoopTracerStartPreservesRecordingParent.
  • go test -run '^TestNoopTracerStartPreservesRecordingParent$' -count=1 . (pass)
  • go test -count=20 -run '^TestNoopTracerStartPreservesRecordingParent$' . (pass)
  • go test ./... from the trace workspace (pass)
  • go vet ./... from the trace workspace (pass)
  • gofmt -d trace/noop.go trace/noop_test.go and git diff --check (pass)
  • /g/OSS-PR-200/work/golangci-lint-6807.exe run --fast-only --timeout 60s --allow-serial-runners from the trace workspace (pass; 0 issues)
  • The same regression test fails on the unchanged default branch at 7430d856c5cb42acf07385036965189ae18d70ab.

Limitations

  • make precommit could not run because make is unavailable on the Windows host.
  • The whole-repository all-module test was attempted, but uncached github.com/go-logr/logr@v1.4.4 could not be downloaded because the host's proxy/GitHub network was intermittent; the complete trace workspace passed.
  • go test -race could not run: the Windows host requires CGO for race mode, and its available clang rejects the required -mthreads target 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.

Signed-off-by: sb123sb123 <152394158+sb123sb123@users.noreply.github.com>
@linux-foundation-easycla

linux-foundation-easycla Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

CLA Not Signed

Signed-off-by: sb123sb123 <152394158+sb123sb123@users.noreply.github.com>
@MrAlias MrAlias added the blocked:CLA Waiting on CLA to be signed before progress can be made label Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked:CLA Waiting on CLA to be signed before progress can be made

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NewNoopTracerProvider when used with WithTracerProvider resets the trace id for inner traces

2 participants