use reth_evm::metrics::ExecutorMetrics;
use reth_metrics::{
metrics::{Counter, Gauge, Histogram},
Metrics,
};
#[derive(Debug, Default)]
pub(crate) struct EngineApiMetrics {
pub(crate) engine: EngineMetrics,
pub(crate) executor: ExecutorMetrics,
pub(crate) block_validation: BlockValidationMetrics,
}
#[derive(Metrics)]
#[metrics(scope = "consensus.engine.beacon")]
pub(crate) struct EngineMetrics {
pub(crate) executed_blocks: Gauge,
pub(crate) pipeline_runs: Counter,
pub(crate) forkchoice_updated_messages: Counter,
pub(crate) new_payload_messages: Counter,
pub(crate) persistence_duration: Histogram,
}
#[derive(Metrics)]
#[metrics(scope = "sync.block_validation")]
pub(crate) struct BlockValidationMetrics {
pub(crate) state_root_histogram: Histogram,
pub(crate) state_root_duration: Gauge,
}
impl BlockValidationMetrics {
pub(crate) fn record_state_root(&self, elapsed_as_secs: f64) {
self.state_root_duration.set(elapsed_as_secs);
self.state_root_histogram.record(elapsed_as_secs);
}
}