The Filtered type unconditionally returns Interest::always from register_callsite(). As a result, if the Filtered type is filtering over a global filter, the global filter has no effect. This seems undesirable. It should either return Interest::sometimes so that enabled is called for each event, or (preferred, for performance) it should pass through to its inner layer's register_callsite() method.
Repro:
use tracing_subscriber::filter::FilterFn;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
use tracing_subscriber::Layer;
fn main() {
let disable_all = FilterFn::new(|_| false);
let enable_all = FilterFn::new(|_| true);
tracing_subscriber::registry()
.with(
Layer::and_then(disable_all, tracing_subscriber::fmt::layer()).with_filter(enable_all),
)
.init();
tracing::info!("you had better not see this");
}
Expected:
[no output]
Actual:
2024-01-24T21:50:12.178070Z INFO bug: you had better not see this
Bug Report
Version
Description
The
Filtered
type unconditionally returnsInterest::always
fromregister_callsite()
. As a result, if theFiltered
type is filtering over a global filter, the global filter has no effect. This seems undesirable. It should either returnInterest::sometimes
so thatenabled
is called for each event, or (preferred, for performance) it should pass through to its inner layer'sregister_callsite()
method.Repro:
Expected:
[no output]
Actual: