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
This commit is contained in:
Tamir Duberstein
2026-10-01 18:02:44 +00:00
committed by copyberry
parent 57a38c1beb
commit d9cf203890
+12 -10
View File
@@ -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]