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"})
|
2021-09-17 11:35:12 +00:00
|
|
|
totalPeerCount = promauto.NewGauge(prometheus.GaugeOpts{
|
|
|
|
Name: "libp2p_peers",
|
|
|
|
Help: "Tracks the total number of libp2p peers",
|
|
|
|
})
|
2020-05-11 04:29:23 +00:00
|
|
|
repeatPeerConnections = promauto.NewCounter(prometheus.CounterOpts{
|
|
|
|
Name: "p2p_repeat_attempts",
|
|
|
|
Help: "The number of repeat attempts the connection handler is triggered for a peer.",
|
|
|
|
})
|
2021-09-01 14:25:22 +00:00
|
|
|
statusMessageMissing = promauto.NewCounter(prometheus.CounterOpts{
|
|
|
|
Name: "p2p_status_message_missing",
|
|
|
|
Help: "The number of attempts the connection handler rejects a peer for a missing status message.",
|
|
|
|
})
|
2020-08-10 15:27:50 +00:00
|
|
|
savedAttestationBroadcasts = promauto.NewCounter(prometheus.CounterOpts{
|
|
|
|
Name: "p2p_attestation_subnet_recovered_broadcasts",
|
|
|
|
Help: "The number of attestations that were attempted to be broadcast with no peers on " +
|
|
|
|
"the subnet. The beacon node increments this counter when the broadcast is blocked " +
|
|
|
|
"until a subnet peer can be found.",
|
|
|
|
})
|
|
|
|
attestationBroadcastAttempts = promauto.NewCounter(prometheus.CounterOpts{
|
|
|
|
Name: "p2p_attestation_subnet_attempted_broadcasts",
|
|
|
|
Help: "The number of attestations that were attempted to be broadcast.",
|
|
|
|
})
|
2021-08-27 01:34:20 +00:00
|
|
|
savedSyncCommitteeBroadcasts = promauto.NewCounter(prometheus.CounterOpts{
|
|
|
|
Name: "p2p_sync_committee_subnet_recovered_broadcasts",
|
|
|
|
Help: "The number of sync committee messages that were attempted to be broadcast with no peers on " +
|
|
|
|
"the subnet. The beacon node increments this counter when the broadcast is blocked " +
|
|
|
|
"until a subnet peer can be found.",
|
|
|
|
})
|
|
|
|
syncCommitteeBroadcastAttempts = promauto.NewCounter(prometheus.CounterOpts{
|
|
|
|
Name: "p2p_sync_committee_subnet_attempted_broadcasts",
|
|
|
|
Help: "The number of sync committee that were attempted to be broadcast.",
|
|
|
|
})
|
2019-12-18 05:31:46 +00:00
|
|
|
)
|
2019-08-24 16:07:03 +00:00
|
|
|
|
2019-12-18 05:31:46 +00:00
|
|
|
func (s *Service) updateMetrics() {
|
2021-09-17 11:35:12 +00:00
|
|
|
totalPeerCount.Set(float64(len(s.peers.Connected())))
|
2019-12-18 05:31:46 +00:00
|
|
|
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
|
|
|
}
|