Skip to content

Commit

Permalink
redisbp: Change stale connections metrics to counter
Browse files Browse the repository at this point in the history
It's actually implemented as a counter under the hood (with atomic adds
on uint32 values), not a gauge.
  • Loading branch information
fishy committed Jul 14, 2022
1 parent 0bba92c commit e34b108
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions redis/db/redisbp/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 (
Expand Down Expand Up @@ -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(
Expand All @@ -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,
)
}

0 comments on commit e34b108

Please sign in to comment.