use core::fmt;
use reth_metrics::{metrics::Counter, Metrics};
#[derive(Metrics, Clone)]
#[metrics(scope = "executor.spawn")]
pub struct TaskExecutorMetrics {
pub(crate) critical_tasks_total: Counter,
pub(crate) finished_critical_tasks_total: Counter,
pub(crate) regular_tasks_total: Counter,
pub(crate) finished_regular_tasks_total: Counter,
}
impl TaskExecutorMetrics {
pub(crate) fn inc_critical_tasks(&self) {
self.critical_tasks_total.increment(1);
}
pub(crate) fn inc_regular_tasks(&self) {
self.regular_tasks_total.increment(1);
}
}
pub struct IncCounterOnDrop(Counter);
impl fmt::Debug for IncCounterOnDrop {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("IncCounterOnDrop").finish()
}
}
impl IncCounterOnDrop {
pub const fn new(counter: Counter) -> Self {
Self(counter)
}
}
impl Drop for IncCounterOnDrop {
fn drop(&mut self) {
self.0.increment(1);
}
}