mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 04:01:51 +00:00
Add sync batch state metrics (#8847)
Co-Authored-By: Jimmy Chen <jchen.tc@gmail.com>
This commit is contained in:
@@ -10,10 +10,22 @@ use std::marker::PhantomData;
|
||||
use std::ops::Sub;
|
||||
use std::time::Duration;
|
||||
use std::time::Instant;
|
||||
use strum::Display;
|
||||
use strum::{Display, EnumIter, IntoStaticStr};
|
||||
use types::Slot;
|
||||
use types::{DataColumnSidecarList, Epoch, EthSpec};
|
||||
|
||||
/// Batch states used as metrics labels.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, EnumIter, IntoStaticStr)]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum BatchMetricsState {
|
||||
AwaitingDownload,
|
||||
Downloading,
|
||||
AwaitingProcessing,
|
||||
Processing,
|
||||
AwaitingValidation,
|
||||
Failed,
|
||||
}
|
||||
|
||||
pub type BatchId = Epoch;
|
||||
|
||||
/// Type of expected batch.
|
||||
@@ -142,6 +154,18 @@ impl<D: Hash> BatchState<D> {
|
||||
pub fn poison(&mut self) -> BatchState<D> {
|
||||
std::mem::replace(self, BatchState::Poisoned)
|
||||
}
|
||||
|
||||
/// Returns the metrics state for this batch.
|
||||
pub fn metrics_state(&self) -> BatchMetricsState {
|
||||
match self {
|
||||
BatchState::AwaitingDownload => BatchMetricsState::AwaitingDownload,
|
||||
BatchState::Downloading(_) => BatchMetricsState::Downloading,
|
||||
BatchState::AwaitingProcessing(..) => BatchMetricsState::AwaitingProcessing,
|
||||
BatchState::Processing(_) => BatchMetricsState::Processing,
|
||||
BatchState::AwaitingValidation(_) => BatchMetricsState::AwaitingValidation,
|
||||
BatchState::Poisoned | BatchState::Failed => BatchMetricsState::Failed,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec, B: BatchConfig, D: Hash> BatchInfo<E, B, D> {
|
||||
|
||||
Reference in New Issue
Block a user