From 6e2dd842edb29d400e45111348abde130fa8d120 Mon Sep 17 00:00:00 2001 From: iamjpotts <8704475+iamjpotts@users.noreply.github.com> Date: Mon, 12 Feb 2024 15:51:55 -0600 Subject: [PATCH] feat(logging): Add numeric elapsed time field elapsed_secs as f64 (#3004) Signed-off-by: Joshua Potts <8704475+iamjpotts@users.noreply.github.com> --- sqlx-core/src/logger.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sqlx-core/src/logger.rs b/sqlx-core/src/logger.rs index 8c0298b4ac..7780fd4cff 100644 --- a/sqlx-core/src/logger.rs +++ b/sqlx-core/src/logger.rs @@ -124,7 +124,10 @@ impl<'q> QueryLogger<'q> { db.statement = sql, rows_affected = self.rows_affected, rows_returned = self.rows_returned, + // Human-friendly - includes units (usually ms). Also kept for backward compatibility ?elapsed, + // Search friendly - numeric + elapsed_secs = elapsed.as_secs_f64(), // When logging to JSON, one can trigger alerts from the presence of this field. slow_threshold=?self.settings.slow_statements_duration, // Make sure to use "slow" in the message as that's likely @@ -139,7 +142,10 @@ impl<'q> QueryLogger<'q> { db.statement = sql, rows_affected = self.rows_affected, rows_returned = self.rows_returned, + // Human-friendly - includes units (usually ms). Also kept for backward compatibility ?elapsed, + // Search friendly - numeric + elapsed_secs = elapsed.as_secs_f64(), ); } }