From 640f5e64a93fe49b90e9bd7a75586449a16eaee6 Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Wed, 23 May 2018 13:45:43 -0700 Subject: [PATCH] etcdserver/api/rafthttp: document round-trip metrics, clean up Signed-off-by: Gyuho Lee --- etcdserver/api/rafthttp/metrics.go | 4 ++-- etcdserver/api/rafthttp/probing_status.go | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/etcdserver/api/rafthttp/metrics.go b/etcdserver/api/rafthttp/metrics.go index 066cba9cc..c63a082f6 100644 --- a/etcdserver/api/rafthttp/metrics.go +++ b/etcdserver/api/rafthttp/metrics.go @@ -53,7 +53,7 @@ var ( []string{"From"}, ) - rtts = prometheus.NewHistogramVec(prometheus.HistogramOpts{ + rttSec = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Namespace: "etcd", Subsystem: "network", Name: "peer_round_trip_time_seconds", @@ -72,5 +72,5 @@ func init() { prometheus.MustRegister(receivedBytes) prometheus.MustRegister(sentFailures) prometheus.MustRegister(recvFailures) - prometheus.MustRegister(rtts) + prometheus.MustRegister(rttSec) } diff --git a/etcdserver/api/rafthttp/probing_status.go b/etcdserver/api/rafthttp/probing_status.go index 63a764884..a8199dfdf 100644 --- a/etcdserver/api/rafthttp/probing_status.go +++ b/etcdserver/api/rafthttp/probing_status.go @@ -44,9 +44,10 @@ func addPeerToProber(lg *zap.Logger, p probing.Prober, id string, us []string) { } else { plog.Errorf("failed to add peer %s into prober", id) } - } else { - go monitorProbingStatus(lg, s, id) + return } + + go monitorProbingStatus(lg, s, id) } func monitorProbingStatus(lg *zap.Logger, s probing.Status, id string) { @@ -83,7 +84,8 @@ func monitorProbingStatus(lg *zap.Logger, s probing.Status, id string) { plog.Warningf("the clock difference against peer %s is too high [%v > %v]", id, s.ClockDiff(), time.Second) } } - rtts.WithLabelValues(id).Observe(s.SRTT().Seconds()) + rttSec.WithLabelValues(id).Observe(s.SRTT().Seconds()) + case <-s.StopNotify(): return }