Adjust tokio metrics for tokio 1.45

This commit is contained in:
Quentin Gliech
2025-05-07 19:25:17 +02:00
parent c25424c1a9
commit e78590748e

View File

@@ -126,7 +126,6 @@ pub fn observe(metrics: RuntimeMetrics) {
.build();
}
#[cfg(tokio_unstable)]
{
let metrics = metrics.clone();
METER
@@ -144,6 +143,19 @@ pub fn observe(metrics: RuntimeMetrics) {
.build();
}
#[cfg(tokio_unstable)]
{
let metrics = metrics.clone();
METER
.u64_observable_counter("tokio_runtime.spawned_tasks_count")
.with_description("The number of tasks spawned in this runtime since it was created.")
.with_unit("{task}")
.with_callback(move |instrument| {
instrument.observe(metrics.spawned_tasks_count(), &[]);
})
.build();
}
#[cfg(tokio_unstable)]
{
let metrics = metrics.clone();
@@ -163,7 +175,6 @@ pub fn observe(metrics: RuntimeMetrics) {
.build();
}
#[cfg(tokio_unstable)]
{
let metrics = metrics.clone();
METER
@@ -247,7 +258,6 @@ pub fn observe(metrics: RuntimeMetrics) {
.build();
}
#[cfg(tokio_unstable)]
{
let metrics = metrics.clone();
METER
@@ -416,7 +426,6 @@ pub fn observe(metrics: RuntimeMetrics) {
}
/// Helper to construct a [`KeyValue`] with the worker index.
#[allow(dead_code)]
fn worker_idx(i: usize) -> KeyValue {
KeyValue::new("worker_idx", i.try_into().unwrap_or(i64::MAX))
}