Skip to content

Commit

Permalink
track dial attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Sep 19, 2022
1 parent 2eee028 commit 5af38d1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions iroh-bitswap/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
9 changes: 9 additions & 0 deletions iroh-metrics/src/bitswap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -214,6 +217,7 @@ impl Metrics {
sent_block_bytes,
received_block_bytes,
providers_total,
attempted_dials,
known_peers,
forgotten_peers,
wanted_blocks,
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -326,6 +332,7 @@ pub enum BitswapMetrics {
BlockBytesIn,
Providers,

AttemptedDials,
KnownPeers,
ForgottenPeers,
WantedBlocks,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 5af38d1

Please sign in to comment.