Skip to content

Commit e929881

Browse files
make live_tasks_count (num_alive_tasks()) stable (#108)
1 parent 115bd06 commit e929881

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

src/runtime.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/runtime/metrics_rs_integration.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ metric_refs! {
249249
stable {
250250
/// The number of worker threads used by the runtime
251251
workers_count: Gauge<Count> [],
252+
/// The current number of alive tasks in the runtime.
253+
live_tasks_count: Gauge<Count> [],
252254
/// The number of times worker threads parked
253255
max_park_count: Gauge<Count> [],
254256
/// The minimum number of times any worker thread parked
@@ -323,8 +325,6 @@ metric_refs! {
323325
min_local_queue_depth: Gauge<Count> [],
324326
/// The number of tasks currently waiting to be executed in the runtime's blocking threadpool.
325327
blocking_queue_depth: Gauge<Count> [],
326-
/// The current number of alive tasks in the runtime.
327-
live_tasks_count: Gauge<Count> [],
328328
/// The number of additional threads spawned by the runtime.
329329
blocking_threads_count: Gauge<Count> [],
330330
/// The number of idle threads, which have spawned by the runtime for `spawn_blocking` calls.

0 commit comments

Comments
 (0)