Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(metrics): count the number of relayed circuit connections #2563

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions ant-networking/src/event/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ impl SwarmDriver {
libp2p::relay::Event::ReservationTimedOut { src_peer_id } => {
self.connected_relay_clients.remove(&src_peer_id);
}
libp2p::relay::Event::CircuitReqAccepted { .. } => {
#[cfg(feature = "open-metrics")]
if let Some(metrics_recorder) = &self.metrics_recorder {
metrics_recorder.open_relayed_circuit_connections.inc();
}
}
libp2p::relay::Event::CircuitClosed { .. } => {
#[cfg(feature = "open-metrics")]
if let Some(metrics_recorder) = &self.metrics_recorder {
metrics_recorder.open_relayed_circuit_connections.dec();
}
}
_ => {}
}
}
Expand Down
8 changes: 8 additions & 0 deletions ant-networking/src/metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub(crate) struct NetworkMetricsRecorder {
pub(crate) connected_peers: Gauge,
pub(crate) estimated_network_size: Gauge,
pub(crate) open_connections: Gauge,
pub(crate) open_relayed_circuit_connections: Gauge,
pub(crate) peers_in_routing_table: Gauge,
pub(crate) records_stored: Gauge,

Expand Down Expand Up @@ -98,6 +99,12 @@ impl NetworkMetricsRecorder {
"The estimated number of nodes in the network calculated by the peers in our RT",
estimated_network_size.clone(),
);
let open_relayed_circuit_connections = Gauge::default();
sub_registry.register(
"open_relayed_circuit_connections",
"The number of active circuit connections that we are relaying between peers",
open_relayed_circuit_connections.clone(),
);
let open_connections = Gauge::default();
sub_registry.register(
"open_connections",
Expand Down Expand Up @@ -214,6 +221,7 @@ impl NetworkMetricsRecorder {
estimated_network_size,
connected_peers,
open_connections,
open_relayed_circuit_connections,
peers_in_routing_table,
relevant_records,
max_records,
Expand Down
Loading