Skip to content

Commit cfb001a

Browse files
committed
Adjust tokio metrics for tokio 1.45
1 parent eb99568 commit cfb001a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

crates/cli/src/telemetry/tokio.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ pub fn observe(metrics: RuntimeMetrics) {
126126
.build();
127127
}
128128

129-
#[cfg(tokio_unstable)]
130129
{
131130
let metrics = metrics.clone();
132131
METER
@@ -144,6 +143,19 @@ pub fn observe(metrics: RuntimeMetrics) {
144143
.build();
145144
}
146145

146+
#[cfg(tokio_unstable)]
147+
{
148+
let metrics = metrics.clone();
149+
METER
150+
.u64_observable_counter("tokio_runtime.spawned_tasks_count")
151+
.with_description("The number of tasks spawned in this runtime since it was created.")
152+
.with_unit("{task}")
153+
.with_callback(move |instrument| {
154+
instrument.observe(metrics.spawned_tasks_count(), &[]);
155+
})
156+
.build();
157+
}
158+
147159
#[cfg(tokio_unstable)]
148160
{
149161
let metrics = metrics.clone();
@@ -163,7 +175,6 @@ pub fn observe(metrics: RuntimeMetrics) {
163175
.build();
164176
}
165177

166-
#[cfg(tokio_unstable)]
167178
{
168179
let metrics = metrics.clone();
169180
METER
@@ -247,7 +258,6 @@ pub fn observe(metrics: RuntimeMetrics) {
247258
.build();
248259
}
249260

250-
#[cfg(tokio_unstable)]
251261
{
252262
let metrics = metrics.clone();
253263
METER
@@ -416,7 +426,6 @@ pub fn observe(metrics: RuntimeMetrics) {
416426
}
417427

418428
/// Helper to construct a [`KeyValue`] with the worker index.
419-
#[allow(dead_code)]
420429
fn worker_idx(i: usize) -> KeyValue {
421430
KeyValue::new("worker_idx", i.try_into().unwrap_or(i64::MAX))
422431
}

0 commit comments

Comments
 (0)