Description:
The server/src/utils/db_timer.rs file provides a log_if_slow utility function that logs a warning when a database query exceeds a threshold. However, this utility is only applied in a few places and does not emit structured log fields (such as query_name, duration_ms, threshold_ms) that would enable dashboards or alerting systems to aggregate slow query data.
All handler functions that run database queries should use log_if_slow with structured fields. The utility function itself should be updated to emit a tracing::warn! event with named fields rather than a format string.
Acceptance Criteria:
log_if_slow emits a tracing::warn! event with fields query_name, duration_ms, and threshold_ms.
- At least the
list_events, get_event, and submit_event_rating handlers use log_if_slow.
- A unit test verifies that the correct fields are included in the warning.
Description:
The
server/src/utils/db_timer.rsfile provides alog_if_slowutility function that logs a warning when a database query exceeds a threshold. However, this utility is only applied in a few places and does not emit structured log fields (such asquery_name,duration_ms,threshold_ms) that would enable dashboards or alerting systems to aggregate slow query data.All handler functions that run database queries should use
log_if_slowwith structured fields. The utility function itself should be updated to emit atracing::warn!event with named fields rather than a format string.Acceptance Criteria:
log_if_slowemits atracing::warn!event with fieldsquery_name,duration_ms, andthreshold_ms.list_events,get_event, andsubmit_event_ratinghandlers uselog_if_slow.