Skip to content

Commit

Permalink
add metrics to gossip
Browse files Browse the repository at this point in the history
  • Loading branch information
lanvidr committed May 27, 2022
1 parent bdf67e4 commit 2183b44
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
25 changes: 25 additions & 0 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ pub struct AuthorityMetrics {
num_input_objs: Histogram,
num_shared_objects: Histogram,
batch_size: Histogram,

pub gossip_queued_count: IntCounter,
pub gossip_sync_count: IntCounter,
pub gossip_task_success_count: IntCounter,
pub gossip_task_error_count: IntCounter,
}

// Override default Prom buckets for positive numbers in 0-50k range
Expand Down Expand Up @@ -162,6 +167,26 @@ impl AuthorityMetrics {
POSITIVE_INT_BUCKETS.to_vec()
)
.unwrap(),
gossip_queued_count: register_int_counter!(
"gossip_queued_count",
"Number of digests queued from gossip peers",
)
.unwrap(),
gossip_sync_count: register_int_counter!(
"gossip_sync_count",
"Number of certificates downloaded from gossip peers"
)
.unwrap(),
gossip_task_success_count: register_int_counter!(
"gossip_task_success_count",
"Number of gossip tasks that completed successfully"
)
.unwrap(),
gossip_task_error_count: register_int_counter!(
"gossip_task_error_count",
"Number of gossip tasks that completed with errors"
)
.unwrap(),
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion crates/sui-core/src/authority_active/gossip/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,15 @@ where
let (finished_name, _result) = gossip_tasks.select_next_some().await;
if let Err(err) = _result {
active_authority.set_failure_backoff(finished_name).await;
active_authority.state.metrics.gossip_task_error_count.inc();
error!("Peer {:?} returned error: {:?}", finished_name, err);
} else {
active_authority.set_success_backoff(finished_name).await;
active_authority
.state
.metrics
.gossip_task_success_count
.inc();
debug!("End gossip from peer {:?}", finished_name);
}
peer_names.remove(&finished_name);
Expand Down Expand Up @@ -194,7 +200,6 @@ where
let result =
tokio::task::spawn(async move { self.peer_gossip_for_duration(duration).await }).await;

// todo: log e
match result {
Err(_e) => (
peer_name,
Expand Down Expand Up @@ -236,6 +241,7 @@ where
tokio::time::sleep(Duration::from_millis(EACH_ITEM_DELAY_MS)).await;
digest
});
self.state.metrics.gossip_queued_count.inc();

}
self.max_seq = Some(seq + 1);
Expand Down Expand Up @@ -283,6 +289,7 @@ where
},
)
.await?;
self.state.metrics.gossip_sync_count.inc();
Ok(())
} else {
// The authority did not return the certificate, despite returning info
Expand Down

0 comments on commit 2183b44

Please sign in to comment.