Skip to content

Commit

Permalink
feat(logging): Add numeric elapsed time field elapsed_ms
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Potts <8704475+iamjpotts@users.noreply.github.com>
  • Loading branch information
iamjpotts committed Jan 25, 2024
1 parent a7862ae commit 96a6ee7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sqlx-core/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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_ms = i64::try_from(elapsed.as_millis()).ok(),
// 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
Expand All @@ -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_ms = i64::try_from(elapsed.as_millis()).ok(),
);
}
}
Expand Down

0 comments on commit 96a6ee7

Please sign in to comment.