From 4d83b687d4eb761d61475dee693c7c0e9fba7ca7 Mon Sep 17 00:00:00 2001 From: sprites0 <199826320+sprites0@users.noreply.github.com> Date: Sun, 5 Oct 2025 11:27:23 +0000 Subject: [PATCH] feat: Add metrics for file read triggered Usually, "Loading block data from ..." shouldn't be shown in logs at all. Add metrics to detect the file read. --- src/pseudo_peer/sources/hl_node/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pseudo_peer/sources/hl_node/mod.rs b/src/pseudo_peer/sources/hl_node/mod.rs index 65eeaf267..9b6c43774 100644 --- a/src/pseudo_peer/sources/hl_node/mod.rs +++ b/src/pseudo_peer/sources/hl_node/mod.rs @@ -52,6 +52,8 @@ pub struct HlNodeBlockSourceMetrics { pub fetched_from_hl_node: Counter, /// How many times the HL node block source is fetched from the fallback pub fetched_from_fallback: Counter, + /// How many times `try_collect_local_block` was faster than ingest loop + pub file_read_triggered: Counter, } impl BlockSource for HlNodeBlockSource { @@ -64,7 +66,9 @@ impl BlockSource for HlNodeBlockSource { Box::pin(async move { let now = OffsetDateTime::now_utc(); - if let Some(block) = Self::try_collect_local_block(local_blocks_cache, height).await { + if let Some(block) = + Self::try_collect_local_block(&metrics, local_blocks_cache, height).await + { Self::update_last_fetch(last_local_fetch, height, now).await; metrics.fetched_from_hl_node.increment(1); return Ok(block); @@ -155,6 +159,7 @@ impl HlNodeBlockSource { } async fn try_collect_local_block( + metrics: &HlNodeBlockSourceMetrics, local_blocks_cache: Arc>, height: u64, ) -> Option { @@ -164,6 +169,7 @@ impl HlNodeBlockSource { } let path = u_cache.get_path_for_height(height)?; info!("Loading block data from {:?}", path); + metrics.file_read_triggered.increment(1); let mut line_stream = LineStream::from_path(&path).ok()?; let scan_result = Scanner::scan_hour_file( &mut line_stream,