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

@@ -12,14 +12,16 @@ use lighthouse_network::{
};
use logging::crit;
use std::hash::{DefaultHasher, Hash, Hasher};
use strum::IntoEnumIterator;
use tracing::{debug, error, info, info_span, warn};
use types::{DataColumnSidecarList, Epoch, EthSpec};
use crate::metrics;
use crate::sync::{
backfill_sync::{BACKFILL_EPOCHS_PER_BATCH, ProcessResult, SyncStart},
batch::{
BatchConfig, BatchId, BatchInfo, BatchOperationOutcome, BatchProcessingResult, BatchState,
ByRangeRequestType,
BatchConfig, BatchId, BatchInfo, BatchMetricsState, BatchOperationOutcome,
BatchProcessingResult, BatchState, ByRangeRequestType,
},
block_sidecar_coupling::CouplingError,
manager::CustodyBatchProcessResult,
@@ -1114,6 +1116,21 @@ impl<T: BeaconChainTypes> CustodyBackFillSync<T> {
*self.network_globals.custody_sync_state.write() = state;
}
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,
&["custody_backfill", state.into()],
count as i64,
);
}
}
/// A fully synced peer has joined us.
/// If we are in a failed state, update a local variable to indicate we are able to restart
/// the failed sync on the next attempt.