From dae62aeb760c3acb18b14be7f03da032dd495e9b Mon Sep 17 00:00:00 2001 From: zeroqn Date: Mon, 24 Aug 2020 13:28:46 +0800 Subject: [PATCH] fix(network): negative connecting metric number (#430) --- core/network/src/peer_manager/mod.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/network/src/peer_manager/mod.rs b/core/network/src/peer_manager/mod.rs index 47542e754..bbecd3286 100644 --- a/core/network/src/peer_manager/mod.rs +++ b/core/network/src/peer_manager/mod.rs @@ -801,7 +801,8 @@ impl PeerManager { } fn new_unidentified_session(&mut self, pubkey: PublicKey, ctx: Arc) { - common_apm::metrics::network::NETWORK_OUTBOUND_CONNECTING_PEERS.dec(); + common_apm::metrics::network::NETWORK_OUTBOUND_CONNECTING_PEERS + .set(self.connecting.len() as i64); let peer_id = pubkey.peer_id(); if let Err(err) = self.new_session_pre_check(&pubkey, &ctx) { @@ -976,7 +977,8 @@ impl PeerManager { attempt.peer.set_connectedness(Connectedness::Unconnectable); } - common_apm::metrics::network::NETWORK_OUTBOUND_CONNECTING_PEERS.dec(); + common_apm::metrics::network::NETWORK_OUTBOUND_CONNECTING_PEERS + .set(self.connecting.len() as i64); // FIXME // if let Some(trust_metric) = attempt.peer.trust_metric() { // trust_metric.bad_events(1); @@ -1489,10 +1491,10 @@ impl Future for PeerManager { ); if !connectable_peers.is_empty() { - common_apm::metrics::network::NETWORK_OUTBOUND_CONNECTING_PEERS - .add(connectable_peers.len() as i64); - self.connect_peers(connectable_peers); + + common_apm::metrics::network::NETWORK_OUTBOUND_CONNECTING_PEERS + .set(self.connecting.len() as i64); } }