master
go 27 lines 483 Bytes
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 package redis
4
5 import (
6 "context"
7 "time"
8 )
9
10 func (c *Collector) collectPingLatency(mx map[string]int64) {
11 c.pingSummary.Reset()
12
13 for i := 0; i < c.PingSamples; i++ {
14 now := time.Now()
15 _, err := c.rdb.Ping(context.Background()).Result()
16 elapsed := time.Since(now)
17
18 if err != nil {
19 c.Debug(err)
20 continue
21 }
22
23 c.pingSummary.Observe(float64(elapsed.Microseconds()))
24 }
25
26 c.pingSummary.WriteTo(mx, "ping_latency", 1, 1)
27 }