mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: add _total suffix to counter metrics (#8263)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
committed by
GitHub
parent
d7e822f9d6
commit
944180348f
@ -328,12 +328,14 @@ impl TaskExecutor {
|
||||
let on_shutdown = self.on_shutdown.clone();
|
||||
|
||||
// Clone only the specific counter that we need.
|
||||
let finished_regular_tasks_metrics = self.metrics.finished_regular_tasks.clone();
|
||||
let finished_regular_tasks_total_metrics =
|
||||
self.metrics.finished_regular_tasks_total.clone();
|
||||
// Wrap the original future to increment the finished tasks counter upon completion
|
||||
let task = {
|
||||
async move {
|
||||
// Create an instance of IncCounterOnDrop with the counter to increment
|
||||
let _inc_counter_on_drop = IncCounterOnDrop::new(finished_regular_tasks_metrics);
|
||||
let _inc_counter_on_drop =
|
||||
IncCounterOnDrop::new(finished_regular_tasks_total_metrics);
|
||||
let fut = pin!(fut);
|
||||
let _ = select(on_shutdown, fut).await;
|
||||
}
|
||||
@ -405,10 +407,11 @@ impl TaskExecutor {
|
||||
.in_current_span();
|
||||
|
||||
// Clone only the specific counter that we need.
|
||||
let finished_critical_tasks_metrics = self.metrics.finished_critical_tasks.clone();
|
||||
let finished_critical_tasks_total_metrics =
|
||||
self.metrics.finished_critical_tasks_total.clone();
|
||||
let task = async move {
|
||||
// Create an instance of IncCounterOnDrop with the counter to increment
|
||||
let _inc_counter_on_drop = IncCounterOnDrop::new(finished_critical_tasks_metrics);
|
||||
let _inc_counter_on_drop = IncCounterOnDrop::new(finished_critical_tasks_total_metrics);
|
||||
let task = pin!(task);
|
||||
let _ = select(on_shutdown, task).await;
|
||||
};
|
||||
|
||||
@ -9,24 +9,24 @@ use reth_metrics::{metrics::Counter, Metrics};
|
||||
#[metrics(scope = "executor.spawn")]
|
||||
pub struct TaskExecutorMetrics {
|
||||
/// Number of spawned critical tasks
|
||||
pub(crate) critical_tasks: Counter,
|
||||
pub(crate) critical_tasks_total: Counter,
|
||||
/// Number of finished spawned critical tasks
|
||||
pub(crate) finished_critical_tasks: Counter,
|
||||
pub(crate) finished_critical_tasks_total: Counter,
|
||||
/// Number of spawned regular tasks
|
||||
pub(crate) regular_tasks: Counter,
|
||||
pub(crate) regular_tasks_total: Counter,
|
||||
/// Number of finished spawned regular tasks
|
||||
pub(crate) finished_regular_tasks: Counter,
|
||||
pub(crate) finished_regular_tasks_total: Counter,
|
||||
}
|
||||
|
||||
impl TaskExecutorMetrics {
|
||||
/// Increments the counter for spawned critical tasks.
|
||||
pub(crate) fn inc_critical_tasks(&self) {
|
||||
self.critical_tasks.increment(1);
|
||||
self.critical_tasks_total.increment(1);
|
||||
}
|
||||
|
||||
/// Increments the counter for spawned regular tasks.
|
||||
pub(crate) fn inc_regular_tasks(&self) {
|
||||
self.regular_tasks.increment(1);
|
||||
self.regular_tasks_total.increment(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user