Add basic metrics to the syncer.

This commit is contained in:
Henry de Valence 2020-07-22 14:46:21 -07:00
parent c2c2a28e8b
commit 4a98b8fa0d
4 changed files with 17 additions and 0 deletions

1
Cargo.lock generated
View File

@ -2592,6 +2592,7 @@ dependencies = [
"color-eyre", "color-eyre",
"futures", "futures",
"futures-util", "futures-util",
"metrics",
"rand 0.7.3", "rand 0.7.3",
"redjubjub", "redjubjub",
"spandoc", "spandoc",

View File

@ -15,6 +15,7 @@ tokio = { version = "0.2.22", features = ["time", "sync", "stream", "tracing"] }
tower = "0.3" tower = "0.3"
tracing = "0.1.16" tracing = "0.1.16"
tracing-futures = "0.2.4" tracing-futures = "0.2.4"
metrics = "0.12"
tower-batch = { path = "../tower-batch/" } tower-batch = { path = "../tower-batch/" }
zebra-chain = { path = "../zebra-chain" } zebra-chain = { path = "../zebra-chain" }

View File

@ -651,6 +651,8 @@ impl Service<Arc<Block>> for CheckpointVerifier {
// TODO(teor): retry on failure (low priority, failures should be rare) // TODO(teor): retry on failure (low priority, failures should be rare)
self.process_checkpoint_range(); self.process_checkpoint_range();
metrics::gauge!("checkpoint.queued_slots", self.queued.len() as i64);
async move { async move {
// Remove the Result<..., RecvError> wrapper from the channel future // Remove the Result<..., RecvError> wrapper from the channel future
rx.await rx.await

View File

@ -67,13 +67,25 @@ where
pub async fn sync(&mut self) -> Result<(), Report> { pub async fn sync(&mut self) -> Result<(), Report> {
loop { loop {
self.obtain_tips().await?; self.obtain_tips().await?;
metrics::gauge!(
"sync.prospective_tips.len",
self.prospective_tips.len() as i64
);
metrics::gauge!("sync.pending_blocks.len", self.pending_blocks.len() as i64);
// ObtainTips Step 6 // ObtainTips Step 6
// //
// If there are any prospective tips, call ExtendTips. Continue this step until there are no more prospective tips. // If there are any prospective tips, call ExtendTips. Continue this step until there are no more prospective tips.
while !self.prospective_tips.is_empty() { while !self.prospective_tips.is_empty() {
tracing::debug!("extending prospective tips"); tracing::debug!("extending prospective tips");
self.extend_tips().await?; self.extend_tips().await?;
metrics::gauge!(
"sync.prospective_tips.len",
self.prospective_tips.len() as i64
);
metrics::gauge!("sync.pending_blocks.len", self.pending_blocks.len() as i64);
tracing::debug!( tracing::debug!(
pending.len = self.pending_blocks.len(), pending.len = self.pending_blocks.len(),
limit = LOOKAHEAD_LIMIT limit = LOOKAHEAD_LIMIT
@ -359,6 +371,7 @@ where
Ok(_) => unreachable!("wrong response to block request"), Ok(_) => unreachable!("wrong response to block request"),
Err(e) => return Err(e), Err(e) => return Err(e),
}; };
metrics::counter!("sync.downloaded_blocks", 1);
verifier.ready_and().await?.call(block).await verifier.ready_and().await?.call(block).await
}) })