feat(dbmanager): report pool max size and total connections opened

Add MaxOpenConnections to provider and connection stats, exposed as the
max state of dbmanager_connection_pool_size. Count physical dials through a
counting driver connector and export dbmanager_connections_opened_total;
existing_db pools derive an approximate count from sql.DBStats.
This commit is contained in:
Hein
2026-09-30 15:46:41 +02:00
parent d3a99550d9
commit 178d40587d
11 changed files with 191 additions and 51 deletions
+6
View File
@@ -112,6 +112,12 @@ func (p *ExistingDBProvider) Stats() *ConnectionStats {
if p.db != nil {
dbStats := p.db.Stats()
stats.OpenConnections = dbStats.OpenConnections
stats.MaxOpenConnections = dbStats.MaxOpenConnections
// The pool was opened outside dbmanager so dials cannot be counted.
// Open plus every connection database/sql retired for idle or
// lifetime limits is a close lower bound (it misses connections
// dropped as broken).
stats.TotalOpened = int64(dbStats.OpenConnections) + dbStats.MaxIdleClosed + dbStats.MaxIdleTimeClosed + dbStats.MaxLifetimeClosed
stats.InUse = dbStats.InUse
stats.Idle = dbStats.Idle
stats.WaitCount = dbStats.WaitCount