From 02fdc1a78b1a6fd356b05dcc7d2a0af5c1c352df Mon Sep 17 00:00:00 2001 From: Emilio Wuerges Date: Tue, 5 Nov 2024 15:04:38 -0300 Subject: [PATCH 1/2] Lower event log level of non-fatal server errors --- src/tracing_utils.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/tracing_utils.rs b/src/tracing_utils.rs index b32170c0..467389a2 100644 --- a/src/tracing_utils.rs +++ b/src/tracing_utils.rs @@ -44,7 +44,25 @@ macro_rules! instrument_result { ($fut:expr, $span:expr) => {{ let fut = async { $fut.await.or_else(|e| { - tracing::error!(error = %e); + match &e { + $crate::error::Error::Server(server_error) => { + match server_error.code { + 1062 => { + tracing::warn!(error = %e, "duplicated entry for key") + } + 1451 => { + tracing::warn!(error = %e, "foreign key violation") + } + 1644 => { + tracing::warn!(error = %e, "user defined exception condition"); + } + _ => tracing::error!(error = %e), + } + }, + e => { + tracing::error!(error = %e); + } + } Err(e) }) }; From 8095ad13016377bd893f5b9f67cde287fc5f0939 Mon Sep 17 00:00:00 2001 From: Emilio Wuerges Date: Tue, 5 Nov 2024 15:24:02 -0300 Subject: [PATCH 2/2] moved instrumented text into comments --- src/tracing_utils.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tracing_utils.rs b/src/tracing_utils.rs index 467389a2..190e5d33 100644 --- a/src/tracing_utils.rs +++ b/src/tracing_utils.rs @@ -47,14 +47,17 @@ macro_rules! instrument_result { match &e { $crate::error::Error::Server(server_error) => { match server_error.code { + // Duplicated entry for key 1062 => { - tracing::warn!(error = %e, "duplicated entry for key") + tracing::warn!(error = %e) } + // Foreign key violation 1451 => { - tracing::warn!(error = %e, "foreign key violation") + tracing::warn!(error = %e) } + // User defined exception condition 1644 => { - tracing::warn!(error = %e, "user defined exception condition"); + tracing::warn!(error = %e); } _ => tracing::error!(error = %e), }