From d9cf203890663ee27969b8e0735e08cf35010bbf Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Thu, 1 Oct 2026 17:46:49 +0000 Subject: [PATCH] Check token estimate filtering directly on the tracing subscriber (#50054) ## What changed Update `post_sampling_token_estimate_is_disabled_by_always_on_sinks` to register explicit event metadata with the subscriber and assert that its interest is `never`. This replaces the scoped default subscriber and global interest-cache rebuild with a direct check of the configured logging layers. GitOrigin-RevId: 7c4ecd9c4adef148fd222394ad1ad326e8033d95 --- codex-rs/core/src/session/turn_tests.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/codex-rs/core/src/session/turn_tests.rs b/codex-rs/core/src/session/turn_tests.rs index f60ea8be7d..85d8fac511 100644 --- a/codex-rs/core/src/session/turn_tests.rs +++ b/codex-rs/core/src/session/turn_tests.rs @@ -46,16 +46,18 @@ fn post_sampling_token_estimate_is_disabled_by_always_on_sinks() { .with(feedback.logger_layer()) .with(tracing_subscriber::fmt::layer().with_filter(codex_state::log_db::default_filter())); - tracing::subscriber::with_default(subscriber, || { - tracing::callsite::rebuild_interest_cache(); - assert!(!tracing::event_enabled!( - target: POST_SAMPLING_TOKEN_ESTIMATE_TARGET, - tracing::Level::TRACE, - turn_id, - estimated_token_count, - message - )); - }); + static METADATA: tracing::Metadata<'static> = tracing::metadata! { + name: "post sampling token estimate filter probe", + target: POST_SAMPLING_TOKEN_ESTIMATE_TARGET, + level: tracing::Level::TRACE, + fields: &["turn_id", "estimated_token_count", "message"], + callsite: &CALLSITE, + kind: tracing::metadata::Kind::EVENT.hint(), + }; + static CALLSITE: tracing::callsite::DefaultCallsite = + tracing::callsite::DefaultCallsite::new(&METADATA); + + assert!(tracing::Subscriber::register_callsite(&subscriber, &METADATA).is_never()); } #[tokio::test]