Skip to content

Commit

Permalink
Set the tracing level explicitly on the layer
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-cattermole committed Jun 7, 2024
1 parent 5ae689e commit b9764e3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions limitador-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,14 +778,12 @@ fn configure_tracing_subscriber(config: &Configuration) {
match config.storage {
StorageConfiguration::InMemory(_) => tracing_subscriber::registry()
.with(fmt_layer(level))
.with(level.max(LevelFilter::INFO))
.with(telemetry_layer(&config.tracing_endpoint))
.with(telemetry_layer(&config.tracing_endpoint, level))
.init(),
_ => tracing_subscriber::registry()
.with(metrics_layer)
.with(fmt_layer(level))
.with(level.max(LevelFilter::INFO))
.with(telemetry_layer(&config.tracing_endpoint))
.with(telemetry_layer(&config.tracing_endpoint, level))
.init(),
}
} else {
Expand Down Expand Up @@ -815,7 +813,7 @@ where
.with_filter(level)
}

fn telemetry_layer<S>(tracing_endpoint: &String) -> impl Layer<S>
fn telemetry_layer<S>(tracing_endpoint: &String, level: LevelFilter) -> impl Layer<S>
where
S: Subscriber + for<'a> tracing_subscriber::registry::LookupSpan<'a>,
{
Expand All @@ -837,5 +835,8 @@ where
.install_batch(opentelemetry_sdk::runtime::Tokio)
.expect("error installing tokio tracing exporter");

tracing_opentelemetry::layer().with_tracer(tracer)
// Set the level to minimum info if tracing enabled
tracing_opentelemetry::layer()
.with_tracer(tracer)
.with_filter(level.max(LevelFilter::INFO))
}

0 comments on commit b9764e3

Please sign in to comment.