Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions node/network/bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,22 @@ impl Metrics {
.inc_by((size * to_peers) as u64);
}
}

fn note_desired_peer_count(&self, peer_set: PeerSet, size: usize) {
self.0.as_ref().map(|metrics| metrics
.desired_peer_count
.with_label_values(&[peer_set.get_protocol_name_static()])
.set(size as u64)
);
}
}

#[derive(Clone)]
struct MetricsInner {
peer_count: prometheus::GaugeVec<prometheus::U64>,
connected_events: prometheus::CounterVec<prometheus::U64>,
disconnected_events: prometheus::CounterVec<prometheus::U64>,
desired_peer_count: prometheus::GaugeVec<prometheus::U64>,

notifications_received: prometheus::CounterVec<prometheus::U64>,
notifications_sent: prometheus::CounterVec<prometheus::U64>,
Expand Down Expand Up @@ -181,6 +190,16 @@ impl metrics::Metrics for Metrics {
)?,
registry,
)?,
desired_peer_count: prometheus::register(
prometheus::GaugeVec::new(
prometheus::Opts::new(
"parachain_desired_peer_count",
"The number of peers that the local node is expected to connect to on a parachain-related peer-set",
),
&["protocol"]
)?,
registry,
)?,
notifications_received: prometheus::register(
prometheus::CounterVec::new(
prometheus::Opts::new(
Expand Down Expand Up @@ -519,6 +538,8 @@ where
"Received a validator connection request",
);

metrics.note_desired_peer_count(peer_set, validator_ids.len());
Comment thread
ordian marked this conversation as resolved.

let (ns, ads) = validator_discovery.on_request(
validator_ids,
peer_set,
Expand Down