- 
                Notifications
    
You must be signed in to change notification settings  - Fork 838
 
Open
Description
Version
$  cargo --version && rustc --version
cargo 1.92.0-nightly (801d9b498 2025-10-04)
rustc 1.92.0-nightly (b925a865e 2025-10-09)
$ cargo tree | rg tracing
tracing-test v0.1.0 (/home/hash/Projects/tracing-test)
├── tracing v0.1.41
│   ├── tracing-attributes v0.1.30 (proc-macro)
│   └── tracing-core v0.1.34
└── tracing-subscriber v0.3.20
    ├── tracing v0.1.41 (*)
    ├── tracing-core v0.1.34 (*)
    └── tracing-log v0.2.0
        └── tracing-core v0.1.34 (*)Platform
$ uname -a 
Linux home 6.17.1-zen1-1-zen #1 ZEN SMP PREEMPT_DYNAMIC x86_64 GNU/LinuxCrates
- tracing-subscriber
 
Description
The span directives doesn't fully work. Only the target part works.
Code snippet
[dependencies]
tracing = "0.1.41"
tracing-subscriber = { version = "0.3.20", features = ["env-filter"] }fn main() {
    // Default traces         = off
    // crate level traces     = info
    // enabled module traces  = trace
    // disabled module traces = off
    // disabled_span traces   = off
    // value=1 traces         = off
    let complicated_filter = format!(
        "info,[disabled_span]=off,[{{value=1}}]=off,[{{value=\"1\"}}]=off,{crate_name}::enabled_module=trace,{crate_name}::disabled_module=off",
        crate_name = env!("CARGO_PKG_NAME").replace("-", "_"),
    );
    tracing_subscriber::fmt()
        .with_env_filter(tracing_subscriber::EnvFilter::new(complicated_filter))
        .init();
    tracing::trace!("This will not be logged: crate level is 'info', but trace level is 'trace'");
    tracing::debug!("This will not be logged: crate level is 'info', but trace level is 'debug'");
    tracing::info!("This will be logged: crate level is 'info' and trace level is 'info'");
    enabled_module::trace();
    disabled_module::trace();
    trace_with_value(1);
    trace_with_value(2);
    tracing::info_span!("disabled_span").in_scope(|| {
        tracing::error!("This should not be logged, but it logged: 'disabled_span' level is 'off' and this trace is in 'disabled_span' span");
    });
    tracing::info!("This will be logged: crate level is 'info' and trace level is 'info'");
}
#[tracing::instrument]
fn trace_with_value(value: usize) {
    if value == 1 {
        tracing::error!(
            "This should not be logged, but it logged: 'value=1' is 'off' and this trace 'value=1'"
        );
    }
}
mod enabled_module {
    #[tracing::instrument]
    pub fn trace() {
        tracing::trace!(
            "This will be logged: crate::enabled_module level is 'trace' and this trace is in crate::enabled_module target"
        );
    }
}
mod disabled_module {
    #[tracing::instrument]
    pub fn trace() {
        tracing::error!(
            "This will not be logged: crate::disabled_module is 'off' and this trace is in crate::enabled_module target"
        );
    }
}Output
2025-10-17T22:42:50.965310Z  INFO tracing_test: This will be logged: crate level is 'info' and trace level is 'info'
2025-10-17T22:42:50.965381Z TRACE trace: tracing_test::enabled_module: This will be logged: crate::enabled_module level is 'trace' and this trace is in crate::enabled_module target
2025-10-17T22:42:50.965470Z ERROR trace_with_value{value=1}: tracing_test: This should not be logged, but it logged: 'value=1' is 'off' and this trace 'value=1'
2025-10-17T22:42:50.965554Z ERROR disabled_span: tracing_test: This should not be logged, but it logged: 'disabled_span' level is 'off' and this trace is in 'disabled_span' span
2025-10-17T22:42:50.965588Z  INFO tracing_test: This will be logged: crate level is 'info' and trace level is 'info'Expected output
Something like:
2025-10-17T22:42:50.965310Z  INFO tracing_test: This will be logged: crate level is 'info' and trace level is 'info'
2025-10-17T22:42:50.965381Z TRACE trace: tracing_test::enabled_module: This will be logged: crate::enabled_module level is 'trace' and this trace is in crate::enabled_module target
2025-10-17T22:42:50.965588Z  INFO tracing_test: This will be logged: crate level is 'info' and trace level is 'info'It does not have ERROR disabled_span: tracing_test, ERROR trace_with_value{value=1}: tracing_test and it should not have it.
Metadata
Metadata
Assignees
Labels
No labels