Skip to content

Commit

Permalink
rafthttp: add 'peer_active_total' metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Gyu-Ho Lee <[email protected]>
  • Loading branch information
gyuho committed Apr 6, 2017
1 parent e1cf766 commit 122eae6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rafthttp/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ var (
[]string{"From"},
)

activePeers = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: "etcd",
Subsystem: "network",
Name: "peer_active_total",
Help: "The total number of active peer connections.",
})

rtts = prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: "etcd",
Subsystem: "network",
Expand All @@ -69,5 +76,6 @@ func init() {
prometheus.MustRegister(receivedBytes)
prometheus.MustRegister(sentFailures)
prometheus.MustRegister(recvFailures)
prometheus.MustRegister(activePeers)
prometheus.MustRegister(rtts)
}
2 changes: 2 additions & 0 deletions rafthttp/peer_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func (s *peerStatus) activate() {
plog.Infof("peer %s became active", s.id)
s.active = true
s.since = time.Now()
activePeers.Inc()
}
}

Expand All @@ -59,6 +60,7 @@ func (s *peerStatus) deactivate(failure failureType, reason string) {
plog.Infof("peer %s became inactive", s.id)
s.active = false
s.since = time.Time{}
activePeers.Dec()
return
}
plog.Debugf(msg)
Expand Down

0 comments on commit 122eae6

Please sign in to comment.