Skip to content

Commit 13006e7

Browse files
committed
use ps variable
1 parent c28dcbb commit 13006e7

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

server/metric.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,19 @@ func (pm *PrometheusMetric) SetMetrics() {
5858

5959
// Set sets all metrics based on Processes
6060
func (pm *PrometheusMetric) Set() {
61-
if len(pm.Server.Processes) == 0 {
61+
ps := pm.Server.Processes
62+
if len(ps) == 0 {
6263
return
6364
}
64-
6565
log.Debugf("Found '%d' processes. Setting metrics...\n", len(pm.Server.Processes))
66-
67-
pm.connCount.Set(float64(len(pm.Server.Processes)))
66+
pm.connCount.Set(float64(len(ps)))
6867

6968
var metricM = map[string]map[string]int{}
7069
// todo: keys should be constant at somewhere else and we should iterate through them
7170
metricM["db"] = map[string]int{}
7271
metricM["host"] = map[string]int{}
7372

74-
for _, p := range pm.Server.Processes {
73+
for _, p := range ps {
7574
// todo: keys should be constant at somewhere else and we should iterate through them
7675
metricM["db"][p.DB]++
7776
metricM["host"][p.Host]++

0 commit comments

Comments
 (0)