Skip to content

test(relay): give trace_context_lookup test a per-statement unique target (#3929) - #3981

Open
iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:claude/issue3929-20260731
Open

test(relay): give trace_context_lookup test a per-statement unique target (#3929)#3981
iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:claude/issue3929-20260731

Conversation

@iroiro147

Copy link
Copy Markdown

Summary

Fixes the intermittent failure of telemetry::tests::trace_context_lookup_does_not_enable_callsites under the parallel buzz-relay lib suite (#3929). The failure is pre-existing on unmodified main (not introduced by any open PR) and never fires when the test is run filtered or standalone.

Root cause

tracing caches callsite interest globally per static callsite, not per-subscriber. The test installs a TraceContextLookup layer with LevelFilter::OFF via a thread-local with_default, then asserts the callsite is not enabled with tracing::enabled!.

When the full lib suite runs in parallel, another test can register a global default dispatcher and evaluate the same static callsite — caching its interest as always while a different subscriber is active. Because that cached interest outlives the other test's subscriber, the thread-local filter is bypassed when this test later runs, and tracing::enabled! returns true. Rebuild/re-registration order depends on parallel scheduling, so whether the poison lands before this test is a race.

Fix (direction 2 — remove the shared state)

The reporter proposed three directions; this takes (2) — a per-run/unique callsite target so no other test can have poisoned this assertion's cached interest — rather than serializing around the shared state with a lock.

The assertion now targets a callsite unique to this test statement: concat!("trace_context_lookup_filter_test_L", line!()). tracing::enabled! requires a compile-time literal target, so this is an inline concat!/line! rather than a runtime format!. Since the callsite is distinct from every other target in the suite, no other test's subscriber activity can poison its cached interest, so the thread-local LevelFilter::OFF is always consulted.

This is a test-only change — no production behavior is altered.

Verification

  • Focused: trace_context_lookup_does_not_enable_callsites passes.
  • telemetry:: module: 7/7 pass.
  • Full cargo test -p buzz-relay --lib: trace_context_lookup_does_not_enable_callsites ... ok. The suite still reports 793 passed; 9 failed; 35 ignored — identical to clean-main baseline; the 9 failures are the pre-existing, unrelated api::media / api::admin panics and are unaffected by this change.

…rget (block#3929)

The test asserted on a shared static callsite target
("trace_context_lookup_filter_test"). tracing caches callsite interest
globally per static callsite rather than per-subscriber, so when the
parallel lib suite ran, another test could poison that callsite's cached
interest while a different subscriber was active — bypassing the
thread-local with_default filter and intermittently failing the
assertion that the LevelFilter::OFF filter disables the callsite.

Use a target literal unique to the test statement (suffixed with the
source line via concat! since enabled! requires a compile-time literal)
so no other test's callsite can poison this assertion's cached interest.
Removes the shared state instead of serializing around it (block#3929, fix
direction 2).

Signed-off-by: iroiro147 <sarthak.singh@juspay.in>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant