2019-08-24 16:07:03 +00:00
|
|
|
package p2p
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2019-12-18 05:31:46 +00:00
|
|
|
p2pPeerCount = promauto.NewGaugeVec(prometheus.GaugeOpts{
|
2019-08-24 16:07:03 +00:00
|
|
|
Name: "p2p_peer_count",
|
2019-12-18 05:31:46 +00:00
|
|
|
Help: "The number of peers in a given state.",
|
|
|
|
},
|
|
|
|
[]string{"state"})
|
|
|
|
)
|
2019-08-24 16:07:03 +00:00
|
|
|
|
2019-12-18 05:31:46 +00:00
|
|
|
func (s *Service) updateMetrics() {
|
|
|
|
p2pPeerCount.WithLabelValues("Connected").Set(float64(len(s.peers.Connected())))
|
|
|
|
p2pPeerCount.WithLabelValues("Disconnected").Set(float64(len(s.peers.Disconnected())))
|
|
|
|
p2pPeerCount.WithLabelValues("Connecting").Set(float64(len(s.peers.Connecting())))
|
|
|
|
p2pPeerCount.WithLabelValues("Disconnecting").Set(float64(len(s.peers.Disconnecting())))
|
2020-01-16 21:07:09 +00:00
|
|
|
p2pPeerCount.WithLabelValues("Bad").Set(float64(len(s.peers.Bad())))
|
2019-08-24 23:56:40 +00:00
|
|
|
}
|