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