github.com/prysmaticlabs/prysm@v1.4.4/beacon-chain/p2p/monitoring.go (about)

     1  package p2p
     2  
     3  import (
     4  	"github.com/prometheus/client_golang/prometheus"
     5  	"github.com/prometheus/client_golang/prometheus/promauto"
     6  )
     7  
     8  var (
     9  	p2pPeerCount = promauto.NewGaugeVec(prometheus.GaugeOpts{
    10  		Name: "p2p_peer_count",
    11  		Help: "The number of peers in a given state.",
    12  	},
    13  		[]string{"state"})
    14  	repeatPeerConnections = promauto.NewCounter(prometheus.CounterOpts{
    15  		Name: "p2p_repeat_attempts",
    16  		Help: "The number of repeat attempts the connection handler is triggered for a peer.",
    17  	})
    18  	savedAttestationBroadcasts = promauto.NewCounter(prometheus.CounterOpts{
    19  		Name: "p2p_attestation_subnet_recovered_broadcasts",
    20  		Help: "The number of attestations that were attempted to be broadcast with no peers on " +
    21  			"the subnet. The beacon node increments this counter when the broadcast is blocked " +
    22  			"until a subnet peer can be found.",
    23  	})
    24  	attestationBroadcastAttempts = promauto.NewCounter(prometheus.CounterOpts{
    25  		Name: "p2p_attestation_subnet_attempted_broadcasts",
    26  		Help: "The number of attestations that were attempted to be broadcast.",
    27  	})
    28  )
    29  
    30  func (s *Service) updateMetrics() {
    31  	p2pPeerCount.WithLabelValues("Connected").Set(float64(len(s.peers.Connected())))
    32  	p2pPeerCount.WithLabelValues("Disconnected").Set(float64(len(s.peers.Disconnected())))
    33  	p2pPeerCount.WithLabelValues("Connecting").Set(float64(len(s.peers.Connecting())))
    34  	p2pPeerCount.WithLabelValues("Disconnecting").Set(float64(len(s.peers.Disconnecting())))
    35  	p2pPeerCount.WithLabelValues("Bad").Set(float64(len(s.peers.Bad())))
    36  }