Add sync batch state metrics (#8847)

Co-Authored-By: Jimmy Chen <jchen.tc@gmail.com>
This commit is contained in:
Jimmy Chen
2026-02-19 12:57:53 +11:00
committed by GitHub
parent 561898fc1c
commit 4588971085
8 changed files with 108 additions and 5 deletions

View File

@@ -8,9 +8,11 @@
//! If a batch fails, the backfill sync cannot progress. In this scenario, we mark the backfill
//! sync as failed, log an error and attempt to retry once a new peer joins the node.
use crate::metrics;
use crate::network_beacon_processor::ChainSegmentProcessId;
use crate::sync::batch::{
BatchConfig, BatchId, BatchInfo, BatchOperationOutcome, BatchProcessingResult, BatchState,
BatchConfig, BatchId, BatchInfo, BatchMetricsState, BatchOperationOutcome,
BatchProcessingResult, BatchState,
};
use crate::sync::block_sidecar_coupling::CouplingError;
use crate::sync::manager::BatchProcessResult;
@@ -31,6 +33,7 @@ use std::collections::{
use std::hash::{Hash, Hasher};
use std::marker::PhantomData;
use std::sync::Arc;
use strum::IntoEnumIterator;
use tracing::{debug, error, info, warn};
use types::{ColumnIndex, Epoch, EthSpec};
@@ -1181,6 +1184,21 @@ impl<T: BeaconChainTypes> BackFillSync<T> {
.epoch(T::EthSpec::slots_per_epoch())
}
pub fn register_metrics(&self) {
for state in BatchMetricsState::iter() {
let count = self
.batches
.values()
.filter(|b| b.state().metrics_state() == state)
.count();
metrics::set_gauge_vec(
&metrics::SYNCING_CHAIN_BATCHES,
&["backfill", state.into()],
count as i64,
);
}
}
/// Updates the global network state indicating the current state of a backfill sync.
fn set_state(&self, state: BackFillState) {
*self.network_globals.backfill_state.write() = state;