From 5af38d18028765ada02782f6e157fdcc71737cc6 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Thu, 8 Sep 2022 14:15:17 +0200 Subject: [PATCH] track dial attempts --- iroh-bitswap/src/behaviour.rs | 1 + iroh-metrics/src/bitswap.rs | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/iroh-bitswap/src/behaviour.rs b/iroh-bitswap/src/behaviour.rs index 7b9bf8dd31..8efd411fed 100644 --- a/iroh-bitswap/src/behaviour.rs +++ b/iroh-bitswap/src/behaviour.rs @@ -429,6 +429,7 @@ impl Bitswap { return None; } state.conn = ConnState::Dialing; + inc!(BitswapMetrics::AttemptedDials); let handler = BitswapHandler::new(config.protocol_config, config.idle_timeout); Some(NetworkBehaviourAction::Dial { opts: DialOpts::peer_id(peer).build(), diff --git a/iroh-metrics/src/bitswap.rs b/iroh-metrics/src/bitswap.rs index f7851aecdd..aed305b5df 100644 --- a/iroh-metrics/src/bitswap.rs +++ b/iroh-metrics/src/bitswap.rs @@ -17,6 +17,7 @@ pub(crate) struct Metrics { providers_total: Counter, // new metrics + attempted_dials: Counter, known_peers: Counter, forgotten_peers: Counter, wanted_blocks: Counter, @@ -89,6 +90,8 @@ impl Metrics { ); // new metrics + let attempted_dials = Counter::default(); + sub_registry.register("attempted_dials", "", Box::new(attempted_dials.clone())); let known_peers = Counter::default(); sub_registry.register("known_peers", "", Box::new(known_peers.clone())); let forgotten_peers = Counter::default(); @@ -214,6 +217,7 @@ impl Metrics { sent_block_bytes, received_block_bytes, providers_total, + attempted_dials, known_peers, forgotten_peers, wanted_blocks, @@ -257,6 +261,8 @@ impl MetricsRecorder for Metrics { self.received_block_bytes.inc_by(value); } else if m.name() == BitswapMetrics::Providers.name() { self.providers_total.inc_by(value); + } else if m.name() == BitswapMetrics::AttemptedDials.name() { + self.attempted_dials.inc_by(value); } else if m.name() == BitswapMetrics::KnownPeers.name() { self.known_peers.inc_by(value); } else if m.name() == BitswapMetrics::ForgottenPeers.name() { @@ -326,6 +332,7 @@ pub enum BitswapMetrics { BlockBytesIn, Providers, + AttemptedDials, KnownPeers, ForgottenPeers, WantedBlocks, @@ -363,6 +370,7 @@ impl MetricType for BitswapMetrics { BitswapMetrics::BlockBytesIn => METRICS_CNT_BLOCK_BYTES_IN, BitswapMetrics::Providers => METRICS_CNT_PROVIDERS_TOTAL, + BitswapMetrics::AttemptedDials => METRICS_CNT_ATTEMPTED_DIALS, BitswapMetrics::KnownPeers => METRICS_CNT_KNOWN_PEERS, BitswapMetrics::ForgottenPeers => METRICS_CNT_FORGOTTEN_PEERS, BitswapMetrics::WantedBlocks => METRICS_CNT_WANTED_BLOCKS, @@ -410,6 +418,7 @@ pub const METRICS_CNT_CANCEL_TOTAL: &str = "canceled"; pub const METRICS_CNT_BLOCK_BYTES_OUT: &str = "block_bytes_out"; pub const METRICS_CNT_BLOCK_BYTES_IN: &str = "block_bytes_in"; pub const METRICS_CNT_PROVIDERS_TOTAL: &str = "providers"; +pub const METRICS_CNT_ATTEMPTED_DIALS: &str = "attempted_dials"; pub const METRICS_CNT_KNOWN_PEERS: &str = "known_peers"; pub const METRICS_CNT_FORGOTTEN_PEERS: &str = "forgotten_peers"; pub const METRICS_CNT_WANTED_BLOCKS: &str = "wanted_blocks";