Skip to content

feat(#358): add database connection pool monitoring metrics#384

Open
Escelit wants to merge 1 commit into
Servora:mainfrom
Escelit:feat/358-db-pool-metrics
Open

feat(#358): add database connection pool monitoring metrics#384
Escelit wants to merge 1 commit into
Servora:mainfrom
Escelit:feat/358-db-pool-metrics

Conversation

@Escelit
Copy link
Copy Markdown

@Escelit Escelit commented Apr 25, 2026

Closes #358

This PR introduces database connection pool monitoring to the MetricsService. Previously, the application lacked visibility into the TypeORM connection pool, making it impossible to detect pool exhaustion under high load.

Changes Made

  • Injected the TypeORM DataSource into MetricsService.
  • Added three new Prometheus Gauge metrics to track the database pool state in real-time:
    • db_pool_active_connections: The number of clients currently checked out and actively executing queries.
    • db_pool_idle_connections: The number of clients currently idle and available in the pool.
    • db_pool_waiting_queries: The number of queued queries waiting for a database connection to become available.

These metrics utilize prom-client's collect callback functions to dynamically evaluate the state of the Postgres pg.Pool underlying the TypeORM connection, providing efficient and real-time observability.

Type of Change

  • New feature (non-breaking change which adds functionality)

Testing

  • Verified metrics compile successfully and the collect methods appropriately handle cases where the pool may not be fully initialized or exposed.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 25, 2026

@Escelit 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

@feyishola
Copy link
Copy Markdown
Contributor

@Escelit pls resolve conflicts

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.

No database connection pool monitoring

2 participants