Skip to content

Commit

Permalink
litep2p: Increment incoming connections metric
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandru Vasile <[email protected]>
  • Loading branch information
lexnv committed Nov 26, 2024
1 parent ff8042d commit 68872d9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion substrate/client/network/src/litep2p/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,16 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkBackend<B, H> 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();

Expand Down

0 comments on commit 68872d9

Please sign in to comment.