diff --git a/limitador-server/src/main.rs b/limitador-server/src/main.rs index 53534a59..bb03412c 100644 --- a/limitador-server/src/main.rs +++ b/limitador-server/src/main.rs @@ -37,6 +37,7 @@ use opentelemetry_otlp::WithExportConfig; use opentelemetry_sdk::propagation::TraceContextPropagator; use opentelemetry_sdk::{trace, Resource}; use prometheus_metrics::PrometheusMetrics; +use tracing_subscriber::Layer; use std::fmt::Display; use std::fs; use std::path::Path; @@ -221,9 +222,9 @@ async fn main() -> Result<(), Box> { .unwrap_or(LevelFilter::ERROR) }); let fmt_layer = if level >= LevelFilter::DEBUG { - tracing_subscriber::fmt::layer().with_span_events(FmtSpan::CLOSE) + tracing_subscriber::fmt::layer().with_span_events(FmtSpan::CLOSE).with_filter(level) } else { - tracing_subscriber::fmt::layer() + tracing_subscriber::fmt::layer().with_filter(level) }; let metrics_layer = MetricsLayer::new() @@ -251,16 +252,16 @@ async fn main() -> Result<(), Box> { KeyValue::new("service.name", "limitador"), ]))) .install_batch(opentelemetry_sdk::runtime::Tokio)?; + let tracing_level = level.max(LevelFilter::INFO); let telemetry_layer = tracing_opentelemetry::layer().with_tracer(tracer); tracing_subscriber::registry() - .with(level) .with(metrics_layer) .with(fmt_layer) + .with(tracing_level) .with(telemetry_layer) .init(); } else { tracing_subscriber::registry() - .with(level) .with(metrics_layer) .with(fmt_layer) .init();