Skip to content

Backend: there is no structured logging for database query durations #889

Description

@Yunusabdul38

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendperformancePerformance bottlenecks or optimizations

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions