etcdserver/api/rafthttp: document round-trip metrics, clean up

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
Gyuho Lee 2018-05-23 13:45:43 -07:00
parent 5a9e48be30
commit 640f5e64a9
2 changed files with 7 additions and 5 deletions

View File

@ -53,7 +53,7 @@ var (
[]string{"From"}, []string{"From"},
) )
rtts = prometheus.NewHistogramVec(prometheus.HistogramOpts{ rttSec = prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: "etcd", Namespace: "etcd",
Subsystem: "network", Subsystem: "network",
Name: "peer_round_trip_time_seconds", Name: "peer_round_trip_time_seconds",
@ -72,5 +72,5 @@ func init() {
prometheus.MustRegister(receivedBytes) prometheus.MustRegister(receivedBytes)
prometheus.MustRegister(sentFailures) prometheus.MustRegister(sentFailures)
prometheus.MustRegister(recvFailures) prometheus.MustRegister(recvFailures)
prometheus.MustRegister(rtts) prometheus.MustRegister(rttSec)
} }

View File

@ -44,9 +44,10 @@ func addPeerToProber(lg *zap.Logger, p probing.Prober, id string, us []string) {
} else { } else {
plog.Errorf("failed to add peer %s into prober", id) plog.Errorf("failed to add peer %s into prober", id)
} }
} else { return
go monitorProbingStatus(lg, s, id)
} }
go monitorProbingStatus(lg, s, id)
} }
func monitorProbingStatus(lg *zap.Logger, s probing.Status, id string) { 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) 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(): case <-s.StopNotify():
return return
} }