Skip to content

Commit

Permalink
Add metric for receiver block backfill failures
Browse files Browse the repository at this point in the history
  • Loading branch information
darunrs committed Jul 23, 2024
1 parent a39f835 commit 48a5651
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions block-streamer/src/block_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,14 @@ async fn process_bitmap_indexer_blocks(

let mut last_published_block_height: u64 = start_block_height;

let indexer_name = indexer.get_full_name();

while let Some(block_height_result) = matching_block_heights.next().await {
match block_height_result {
Ok(block_height) => {
metrics::RECEIVER_BLOCKS_FAILURE
.with_label_values(&[&indexer_name])
.set(0);
redis
.publish_block(indexer, redis_stream.clone(), block_height, MAX_STREAM_SIZE)
.await?;
Expand All @@ -422,6 +427,9 @@ async fn process_bitmap_indexer_blocks(
last_published_block_height = block_height;
}
Err(err) => {
metrics::RECEIVER_BLOCKS_FAILURE
.with_label_values(&[&indexer_name])
.inc();
tracing::error!(
"Backfill using bitmap indexer failed unexpectedly: {:?}",
err
Expand Down
6 changes: 6 additions & 0 deletions block-streamer/src/graphql/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ impl GraphQLClientImpl {
.json(&body)
.send()
.await?;
if reqwest_response.status() != 200 {
tracing::error!(
"GraphQL query failed with status code: {}",
reqwest_response.status()
);
}

reqwest_response.json().await
}
Expand Down
6 changes: 6 additions & 0 deletions block-streamer/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ lazy_static! {
&["indexer"]
)
.unwrap();
pub static ref RECEIVER_BLOCKS_FAILURE: IntGaugeVec = register_int_gauge_vec!(
"queryapi_block_streamer_receiver_blocks_failure",
"Gauge which only has a nonzero value if an error occurs during receiver block backfill",
&["indexer"]
)
.unwrap();
}

pub struct LogCounter;
Expand Down

0 comments on commit 48a5651

Please sign in to comment.