From c002dffade32a3566f21f7919b32512a859369ff Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 25 May 2023 02:49:59 +0800 Subject: [PATCH] refactor(frontend): refactor query log by using structured fields (#9989) Co-authored-by: xxchan --- src/utils/pgwire/src/pg_protocol.rs | 31 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/utils/pgwire/src/pg_protocol.rs b/src/utils/pgwire/src/pg_protocol.rs index ddf0ead50b358..97a4cee5a2b8c 100644 --- a/src/utils/pgwire/src/pg_protocol.rs +++ b/src/utils/pgwire/src/pg_protocol.rs @@ -344,11 +344,11 @@ where let truncated_sql = &sql[..std::cmp::min(sql.len(), 1024)]; tracing::info!( target: PGWIRE_QUERY_LOG, - "(simple query) session: {}, status: {}, time: {}ms, sql: {}", - session_id, - if result.is_ok() { "ok" } else { "err" }, - mills, - truncated_sql + mode = %"(simple query)", + session = %session_id, + status = %if result.is_ok() { "ok" } else { "err" }, + time = %format!("{}ms", mills), + sql = %truncated_sql, ); result @@ -440,11 +440,11 @@ where let truncated_sql = &sql[..std::cmp::min(sql.len(), 1024)]; tracing::info!( target: PGWIRE_QUERY_LOG, - "(extended query parse) session: {}, status: {}, time: {}ms, sql: {}", - session_id, - if result.is_ok() { "ok" } else { "err" }, - mills, - truncated_sql + mode = %"(extended query parse)", + session = %session_id, + status = %if result.is_ok() { "ok" } else { "err" }, + time = %format!("{}ms", mills), + sql = %truncated_sql, ); result @@ -581,13 +581,14 @@ where let result = session.execute(portal).await; let mills = start.elapsed().as_millis(); + tracing::info!( target: PGWIRE_QUERY_LOG, - "(extended query execute) session: {}, status: {}, time: {}ms, sql: {}", - session_id, - if result.is_ok() { "ok" } else { "err" }, - mills, - truncated_sql + mode = %"(extended query execute)", + session = %session_id, + status = %if result.is_ok() { "ok" } else { "err" }, + time = %format!("{}ms", mills), + sql = %truncated_sql, ); let pg_response = match result {