Skip to content

feat(db): add structured logging for database connection pool events … - #787

Open
extolkom wants to merge 1 commit into
accesslayerorg:mainfrom
extolkom:feat/764-pool-connection-structured-logs
Open

feat(db): add structured logging for database connection pool events …#787
extolkom wants to merge 1 commit into
accesslayerorg:mainfrom
extolkom:feat/764-pool-connection-structured-logs

Conversation

@extolkom

Copy link
Copy Markdown
Contributor

Summary

Closes #764

Database connection pool exhaustion was previously invisible until requests
started timing out. This adds structured debug-level logging on pool acquire
and release events, plus a warn-level log when acquisition wait time exceeds
1000ms, so operators can monitor pool health proactively.

Changes

  • Added src/utils/db-pool-log.utils.ts with logDbPoolAcquire and
    logDbPoolRelease helpers
  • Wired both into the Prisma client query extension middleware in
    src/utils/prisma.utils.ts
  • Added unit tests in src/utils/db-pool-log.utils.test.ts (10 cases),
    including a boundary test at exactly 1000ms vs 1001ms

Acceptance Criteria

  • Debug log on acquire with all four fields (pool_size, idle_count,
    wait_time_ms, acquired_at)
  • Debug log on release with all three fields (pool_size, idle_count,
    held_for_ms)
  • Warn log when wait time exceeds 1000ms
  • Log level is debug for normal events

Testing

  • pnpm test src/utils/db-pool-log.utils.test.ts — 10/10 passing
  • pnpm check (eslint + tsc) — 0 errors
  • npx prettier --check — passing
  • Branch rebased cleanly onto latest origin/main, no conflicts

Notes for reviewers

Field naming follows the repo's existing snake_case convention used
elsewhere in the logging utils. No new logging dependency was introduced —
this reuses the existing logger already in use in prisma.utils.ts.

@drips-wave

drips-wave Bot commented Aug 25, 2026

Copy link
Copy Markdown

@extolkom Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add structured log for each database connection pool event including pool size and wait time

1 participant