From f85a61ceac4c261d7e73449eb1198efd35a307e8 Mon Sep 17 00:00:00 2001 From: Dmitry Ivanov Date: Mon, 3 Apr 2023 17:55:16 +0300 Subject: [PATCH] [proxy] Fix regression in logging For some reason, `tracing::instrument` proc_macro doesn't always print elements specified via `fields()` or even show that it's impossible (e.g. there's no Display impl). Work around this using the `?foo` notation. Before: 2023-04-03T14:48:06.017504Z INFO handle_client:handshake: received SslRequest After: 2023-04-03T14:51:24.424176Z INFO handle_client{session_id=7bd07be8-3462-404e-8ccc-0a5332bf3ace}:handshake: received SslRequest --- proxy/src/auth/backend.rs | 2 +- proxy/src/proxy.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/proxy/src/auth/backend.rs b/proxy/src/auth/backend.rs index b8599adaeb..18bc80d523 100644 --- a/proxy/src/auth/backend.rs +++ b/proxy/src/auth/backend.rs @@ -140,7 +140,7 @@ async fn auth_quirks( impl BackendType<'_, ClientCredentials<'_>> { /// Authenticate the client via the requested backend, possibly using credentials. - #[tracing::instrument(fields(allow_cleartext), skip_all)] + #[tracing::instrument(fields(allow_cleartext = allow_cleartext), skip_all)] pub async fn authenticate( &mut self, extra: &ConsoleReqExtra<'_>, diff --git a/proxy/src/proxy.rs b/proxy/src/proxy.rs index efe0e8795b..03c9c72f30 100644 --- a/proxy/src/proxy.rs +++ b/proxy/src/proxy.rs @@ -98,7 +98,7 @@ pub async fn task_main( } // TODO(tech debt): unite this with its twin below. -#[tracing::instrument(fields(session_id), skip_all)] +#[tracing::instrument(fields(session_id = ?session_id), skip_all)] pub async fn handle_ws_client( config: &'static ProxyConfig, cancel_map: &CancelMap, @@ -140,7 +140,7 @@ pub async fn handle_ws_client( .await } -#[tracing::instrument(fields(session_id), skip_all)] +#[tracing::instrument(fields(session_id = ?session_id), skip_all)] async fn handle_client( config: &'static ProxyConfig, cancel_map: &CancelMap,