From 782b171cc18c5f82b4eaa83968a99980812ffad2 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Thu, 25 Jul 2024 13:48:52 +1000 Subject: [PATCH] chore(relay): always log setup on trace (#6031) In staging and production, setting up the logger for the relay is a fairly complicated setup. To make debugging easier, we always log these initial steps on `TRACE` level until the real logger is initialised. --- rust/relay/src/main.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rust/relay/src/main.rs b/rust/relay/src/main.rs index 751e758da..f6d905b53 100644 --- a/rust/relay/src/main.rs +++ b/rust/relay/src/main.rs @@ -184,7 +184,9 @@ fn setup_tracing(args: &Args) -> Result<()> { ); let dispatch: Dispatch = match args.otlp_grpc_endpoint.clone() { - None => tracing_subscriber::registry().with(log_layer(args)).into(), + None => tracing_subscriber::registry() + .with(log_layer(args).with_filter(env_filter())) + .into(), Some(endpoint) => { let grpc_endpoint = format!("http://{endpoint}"); @@ -218,7 +220,7 @@ fn setup_tracing(args: &Args) -> Result<()> { tracing::trace!(target: "relay", "Successfully initialized metric controller on tokio runtime"); tracing_subscriber::registry() - .with(log_layer(args)) + .with(log_layer(args).with_filter(env_filter())) .with( tracing_opentelemetry::layer() .with_tracer(provider.tracer("relay")) @@ -248,7 +250,7 @@ fn log_layer(args: &Args) -> Box + Send + Sync> where T: Subscriber + for<'a> tracing_subscriber::registry::LookupSpan<'a>, { - let log_layer = match (args.log_format, args.google_cloud_project_id.clone()) { + match (args.log_format, args.google_cloud_project_id.clone()) { (LogFormat::Human, _) => tracing_subscriber::fmt::layer().boxed(), (LogFormat::Json, _) => tracing_subscriber::fmt::layer().json().boxed(), (LogFormat::GoogleCloud, None) => { @@ -259,9 +261,7 @@ where (LogFormat::GoogleCloud, Some(project_id)) => tracing_stackdriver::layer() .with_cloud_trace(CloudTraceConfiguration { project_id }) .boxed(), - }; - - log_layer.with_filter(env_filter()).boxed() + } } fn env_filter() -> EnvFilter {