@@ -47,12 +47,11 @@ impl Metrics {
4747 }
4848
4949 pub fn note_peer_count ( & self , peer_set : PeerSet , version : ProtocolVersion , count : usize ) {
50- self . 0 . as_ref ( ) . map ( |metrics| {
51- metrics
52- . peer_count
53- . with_label_values ( & [ peer_set_label ( peer_set, version) ] )
54- . set ( count as u64 )
55- } ) ;
50+ if let Some ( metrics) = self . 0 . as_ref ( ) {
51+ let label = peer_set_label ( peer_set, version) ;
52+ metrics. peer_count . with_label_values ( & [ label] ) . set ( count as u64 ) ;
53+ metrics. peer_connectivity . with_label_values ( & [ label] ) . observe ( count as f64 ) ;
54+ }
5655 }
5756
5857 pub fn on_notification_received (
@@ -131,6 +130,7 @@ impl Metrics {
131130#[ derive( Clone ) ]
132131pub ( crate ) struct MetricsInner {
133132 peer_count : prometheus:: GaugeVec < prometheus:: U64 > ,
133+ peer_connectivity : prometheus:: HistogramVec ,
134134 connected_events : prometheus:: CounterVec < prometheus:: U64 > ,
135135 disconnected_events : prometheus:: CounterVec < prometheus:: U64 > ,
136136 desired_peer_count : prometheus:: GaugeVec < prometheus:: U64 > ,
@@ -165,6 +165,16 @@ impl metrics::Metrics for Metrics {
165165 ) ?,
166166 registry,
167167 ) ?,
168+ peer_connectivity : prometheus:: register (
169+ prometheus:: HistogramVec :: new (
170+ prometheus:: HistogramOpts :: new (
171+ "polkadot_parachain_peer_connectivity" ,
172+ "Histogram of peer counts on a parachain-related peer-set to track connectivity patterns" ,
173+ ) . buckets ( vec ! [ 0.0 , 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 10.0 , 15.0 , 20.0 , 25.0 , 30.0 , 40.0 , 50.0 , 100.0 , 250.0 , 500.0 , 1000.0 ] ) ,
174+ & [ "protocol" ]
175+ ) ?,
176+ registry,
177+ ) ?,
168178 connected_events : prometheus:: register (
169179 prometheus:: CounterVec :: new (
170180 prometheus:: Opts :: new (
0 commit comments