test(relay): give trace_context_lookup test a per-statement unique target (#3929) - #3981
Open
iroiro147 wants to merge 1 commit into
Open
test(relay): give trace_context_lookup test a per-statement unique target (#3929)#3981iroiro147 wants to merge 1 commit into
iroiro147 wants to merge 1 commit into
Conversation
…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>
This was referenced Aug 1, 2026
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.
Summary
Fixes the intermittent failure of
telemetry::tests::trace_context_lookup_does_not_enable_callsitesunder the parallelbuzz-relaylib suite (#3929). The failure is pre-existing on unmodifiedmain(not introduced by any open PR) and never fires when the test is run filtered or standalone.Root cause
tracingcaches callsite interest globally per static callsite, not per-subscriber. The test installs aTraceContextLookuplayer withLevelFilter::OFFvia a thread-localwith_default, then asserts the callsite is not enabled withtracing::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
alwayswhile 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, andtracing::enabled!returnstrue. 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 inlineconcat!/line!rather than a runtimeformat!. 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-localLevelFilter::OFFis always consulted.This is a test-only change — no production behavior is altered.
Verification
trace_context_lookup_does_not_enable_callsitespasses.telemetry::module: 7/7 pass.cargo test -p buzz-relay --lib:trace_context_lookup_does_not_enable_callsites ... ok. The suite still reports793 passed; 9 failed; 35 ignored— identical to clean-main baseline; the 9 failures are the pre-existing, unrelatedapi::media/api::adminpanics and are unaffected by this change.