From 68872d997f0e7e0b18ca4d7abc339af03cd17b13 Mon Sep 17 00:00:00 2001 From: Alexandru Vasile Date: Tue, 26 Nov 2024 15:49:46 +0200 Subject: [PATCH] litep2p: Increment incoming connections metric Signed-off-by: Alexandru Vasile --- substrate/client/network/src/litep2p/mod.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/substrate/client/network/src/litep2p/mod.rs b/substrate/client/network/src/litep2p/mod.rs index c1c0c091eaf2..b5cc57ccff9f 100644 --- a/substrate/client/network/src/litep2p/mod.rs +++ b/substrate/client/network/src/litep2p/mod.rs @@ -994,7 +994,16 @@ impl NetworkBackend for Litep2pNetworkBac let direction = match endpoint { Endpoint::Dialer { .. } => "out", - Endpoint::Listener { .. } => "in", + Endpoint::Listener { .. } => { + // Increment incoming connections counter. + // + // Note: For litep2p these are represented by established connections, + // while in libp2p (legacy) these are not-yet-negotiated connections. However, + // wasting CPU cycles does not justify a slight difference in the metric. + metrics.incoming_connections_total.inc(); + + "in" + }, }; metrics.connections_opened_total.with_label_values(&[direction]).inc();