From e34b108af09beab61f33126dfacf075ff58f5116 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Wed, 13 Jul 2022 15:14:34 -0700 Subject: [PATCH] redisbp: Change stale connections metrics to counter It's actually implemented as a counter under the hood (with atomic adds on uint32 values), not a gauge. --- redis/db/redisbp/prometheus.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/redis/db/redisbp/prometheus.go b/redis/db/redisbp/prometheus.go index 29eefa8a1..3908d5d1b 100644 --- a/redis/db/redisbp/prometheus.go +++ b/redis/db/redisbp/prometheus.go @@ -40,6 +40,12 @@ var ( promLabels, nil, ) + staleConnectionsCounterDesc = prometheus.NewDesc( + prometheus.BuildFQName(promNamespace, subsystemPool, "stale_connections_total"), + "Number of stale connections removed from this redisbp pool", + promLabels, + nil, + ) // Gauges. totalConnectionsDesc = prometheus.NewDesc( @@ -54,12 +60,6 @@ var ( promLabels, nil, ) - staleConnectionsDesc = prometheus.NewDesc( - prometheus.BuildFQName(promNamespace, subsystemPool, "stale_connections"), - "Number of stale connections in this redisbp pool", - promLabels, - nil, - ) ) var ( @@ -111,6 +111,12 @@ func (e exporter) Collect(ch chan<- prometheus.Metric) { float64(stats.Timeouts), e.name, ) + ch <- prometheus.MustNewConstMetric( + staleConnectionsCounterDesc, + prometheus.CounterValue, + float64(stats.StaleConns), + e.name, + ) // Gauges. ch <- prometheus.MustNewConstMetric( @@ -125,10 +131,4 @@ func (e exporter) Collect(ch chan<- prometheus.Metric) { float64(stats.IdleConns), e.name, ) - ch <- prometheus.MustNewConstMetric( - staleConnectionsDesc, - prometheus.GaugeValue, - float64(stats.StaleConns), - e.name, - ) }