Skip to content

Expose pool utilization stats from src/db/index.ts for the diagnostics endpoint #170

Description

@Jagadeeshftw

📌 Description

src/db/index.ts creates the pg pool but doesn't expose its utilization (active/idle/waiting connection counts), making it hard to diagnose connection-pool exhaustion from src/routes/diagnostics.ts or logs.

🧩 Requirements and context

  • Export a function from src/db/index.ts that reads the pool's current totalCount/idleCount/waitingCount.
  • Surface these stats from src/routes/diagnostics.ts.
  • No change to pool behavior, purely observability.

🛠️ Suggested execution

  1. Add a getPoolStats() export in src/db/index.ts.
  2. Call it from the diagnostics handler and include the stats in the response.
  3. Add a test asserting the stats reflect actual pool state (e.g. after acquiring a client).

✅ Acceptance criteria

  • getPoolStats() returns accurate active/idle/waiting counts.
  • Diagnostics response includes these stats.

🔒 Security notes

None — this is read-only observability, ensure it doesn't expose connection strings.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions