@@ -150,6 +150,12 @@ define_runtime_metrics! {
150150 /// ```
151151 pub workers_count: usize ,
152152
153+ /// The current number of alive tasks in the runtime.
154+ ///
155+ /// ##### Definition
156+ /// This metric is derived from [`tokio::runtime::RuntimeMetrics::num_alive_tasks`].
157+ pub live_tasks_count: usize ,
158+
153159 /// The number of times worker threads parked.
154160 ///
155161 /// The worker park count increases by one each time the worker parks the thread waiting for
@@ -1155,12 +1161,6 @@ define_runtime_metrics! {
11551161 /// This metric is derived from [`tokio::runtime::RuntimeMetrics::blocking_queue_depth`].
11561162 pub blocking_queue_depth: usize ,
11571163
1158- /// The current number of alive tasks in the runtime.
1159- ///
1160- /// ##### Definition
1161- /// This metric is derived from [`tokio::runtime::RuntimeMetrics::num_alive_tasks`].
1162- pub live_tasks_count: usize ,
1163-
11641164 /// The number of additional threads spawned by the runtime.
11651165 ///
11661166 /// ##### Definition
@@ -1267,6 +1267,7 @@ impl RuntimeIntervals {
12671267
12681268 let mut metrics = RuntimeMetrics {
12691269 workers_count : self . runtime . num_workers ( ) ,
1270+ live_tasks_count : self . runtime . num_alive_tasks ( ) ,
12701271 elapsed : now - self . started_at ,
12711272 global_queue_depth : self . runtime . global_queue_depth ( ) ,
12721273 min_park_count : u64:: MAX ,
@@ -1556,12 +1557,6 @@ impl Worker {
15561557 // Blocking queue depth is an absolute value too
15571558 metrics. blocking_queue_depth = rt. blocking_queue_depth ( ) ;
15581559
1559- #[ allow( deprecated) ]
1560- {
1561- // use the deprecated active_tasks_count here to support slightly older versions of Tokio,
1562- // it's the same.
1563- metrics. live_tasks_count = rt. active_tasks_count ( ) ;
1564- }
15651560 metrics. blocking_threads_count = rt. num_blocking_threads ( ) ;
15661561 metrics. idle_blocking_threads_count = rt. num_idle_blocking_threads ( ) ;
15671562 }
0 commit comments