Open pitoniak32 opened 7 months ago
Seems to be working for me... Can you post the setup of the registry and layers?
I call this from main after parsing the clap-cli for the verbosity, and before the code
fn configure_tracing(log_filter: LevelFilter) -> Result<()> {
tracing_subscriber::registry()
.with(
// set layer for log subscriber
tracing_subscriber::fmt::layer()
.pretty()
.with_filter(log_filter),
)
.with(std::env::var("OTEL_COLLECTOR_URL").map_or_else(
|_| None,
|url| {
Some(
tracing_opentelemetry::layer()
.with_tracer(
opentelemetry_otlp::new_pipeline()
.tracing()
.with_exporter(
opentelemetry_otlp::new_exporter()
.tonic()
.with_endpoint(url),
)
.with_trace_config(
opentelemetry_sdk::trace::config().with_resource(
Resource::new(vec![KeyValue::new(
opentelemetry_semantic_conventions::resource::SERVICE_NAME
.to_string(),
env!("CARGO_PKG_NAME"),
)]),
),
)
.install_batch(opentelemetry_sdk::runtime::Tokio)
.expect("Failed creating the tracer!"),
)
.with_filter(
// If no `RUST_LOG` is provided use info.
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "info".into()),
),
)
},
))
.init();
Ok(())
}
Works for me with this code... could you maybe post a minimal example without the opentel layer?
Works for me with this code... could you maybe post a minimal example without the opentel layer?
for sure, I will try and recreate when I get out of work today 👍🏼
So I tried making a min reproduction, and am not seeing the issue anymore. I started playing around with the way I setup to get the error, and it seems like my .with_filter(...)
on the otel layer is bleeding into the fmt layer 🤔
but it only happens with the inline function calls for the event macros 😓
Bug Report
Version
Platform
Crates
these are the crates in my
Cargo.toml
. I am suspecting the issue is intracing
because its dealing with the event level macros.Description
I am setting up a project that is using 2 subscribers in a Registry.
tracing_subscriber::fmt::layer().pretty().with_filter(log_filter)
tracing_opentelemetry::layer().with_tracer(...).with_filter(LevelFilter::TRACE)
So I can ship at different filter levels to each. I noticed that one of my
info!()
calls was still showing in the logs no mater what I had the level of the fmt subscriber. I was able to reproduce it.This is the behavior I am seeing:
results in:
I am expecting to see none of these events in the logs because the filter level is ERROR, and it behaves like that other than when calling the function to get name directly in the macro.
Its not a huge deal for me to just use a variable, I just wanted to bring attention to this. It was very confusing at first, and I thought it was something to do with my layer filters.
Please let me know if you need any other details! I am willing to give more code, or even make a minimal reproduction if needed. Thank you for working on such an amazing project :)