Skip to content

Add database query performance monitoring and slow query logging interceptor #122

Description

@Cjay-Cyber-2

Description — what to implement and the why/impact.

Maintaining high database performance for financial operations on Stellar requires proactive detection of slow or unindexed queries. This task implements a Prisma client extension or NestJS interceptor that logs query execution durations and emits warning logs when queries exceed defined execution time thresholds.

Context & Requirements — background, constraints, design references, edge cases; grounded in the actual repo (real files, stack, conventions).

The application uses Prisma ORM with PostgreSQL. Prisma supports client middleware and extensions that intercept $query or model operations. We need an extension or logger wrapper that measures execution time, captures query parameters safely (omitting sensitive keys), and logs warnings via the NestJS Logger when latency crosses a configurable threshold (e.g., 250ms).

Acceptance Criteria — a checklist ("- [ ] ...") of specific, testable conditions that define "done".

  • Implement a Prisma client extension measuring execution duration for database operations.
  • Log warning metrics for queries exceeding the latency threshold along with operation names.
  • Ensure sensitive data or private keys are sanitized from logged query parameters.
  • Add unit tests verifying threshold detection and warning log emission.

Implementation Guidance — likely files/modules to touch (use real paths from the repo context) and a suggested approach, without over-prescribing.

Inspect src/database where Prisma service and client instances are initialized. Integrate the extension during Prisma client setup.

Testing & Validation — how the contributor should prove it works (tests to add/run, manual checks, screenshots for UI).

Run npm test and npm run typecheck to ensure type safety across Prisma client extensions.

Submission Guidelines — must open a PR that includes "Closes #"; assignment is required before starting; follow the repo's existing style and conventions.


Wave complexity: Medium

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions