Skip to content

Commit 0f811c5

Browse files
author
Christian Roessner
committed
Feat: Add LDAPStaleConnections metric
Introduce a new gauge metric to track the number of stale connections in the LDAP pool. This addition helps in monitoring and managing the health of the LDAP connections effectively. Signed-off-by: Christian Roessner <[email protected]>
1 parent 7e84e26 commit 0f811c5

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

server/backend/ldap.go

+1
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ func (l *LDAPPool) updateSingleConnectionStatus(index int) int {
381381
func (l *LDAPPool) closeIdleConnections(openConnections, idlePoolSize, poolSize int) {
382382
needClosing := max(openConnections-idlePoolSize, 0)
383383

384+
stats.LDAPStaleConnections.WithLabelValues(l.name).Set(float64(needClosing))
384385
util.DebugModule(global.DbgLDAPPool, global.LogKeyLDAPPoolName, l.name, global.LogKeyMsg, "State open connections", "needClosing", needClosing, "openConnections", openConnections, "idlePoolSize", idlePoolSize)
385386

386387
//goland:noinspection GoDfaConstantCondition

server/stats/statistics.go

+6
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ var (
241241
Help: "Number of currently opened connections",
242242
}, []string{"pool"})
243243

244+
// LDAPStaleConnections counts the number of currently staled connections in the LDAP pool which need closing.
245+
LDAPStaleConnections = promauto.NewGaugeVec(prometheus.GaugeOpts{
246+
Name: "ldap_pool_stale_connections_total",
247+
Help: "Number of currently staled connections",
248+
}, []string{"pool"})
249+
244250
// LDAPPoolSize is a gauge metric that represents the size of the LDAP connection pool.
245251
LDAPPoolSize = promauto.NewGaugeVec(prometheus.GaugeOpts{
246252
Name: "ldap_pool_size",

0 commit comments

Comments
 (0)