Skip to content

Commit 1fcaaa4

Browse files
Add polkadot_parachain_peer_connectivity metric (#8973)
# Description Fixes #8911 Adds `polkadot_parachain_peer_connectivity` histogram metric to better understand connectivity patterns. ## Integration Doesn't affect downstream projects. --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 9b4cfe6 commit 1fcaaa4

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

polkadot/node/network/bridge/src/metrics.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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)]
132131
pub(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(

prdoc/pr_8973.prdoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
title: Add polkadot_parachain_peer_connectivity metric
2+
doc:
3+
- audience: Node Dev
4+
description: |-
5+
Adds `polkadot_parachain_peer_connectivity` histogram metric to better understand connectivity patterns.
6+
7+
crates:
8+
- name: polkadot-network-bridge
9+
bump: patch

0 commit comments

Comments
 (0)