metrics: properly annotate required features for 64-bit-only metrics (#7449)

This commit is contained in:
Jess Izen 2025-07-09 06:03:22 -07:00 committed by GitHub
parent 7dd4d8a30e
commit 888ee60e41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 573 additions and 536 deletions

View File

@ -1,5 +1,26 @@
#![allow(unused_macros)]
/// Allows specifying arbitrary combinations of features and config flags,
/// which are also propagated to `docsrs` config.
///
/// Each contained item will have the annotations applied
///
/// ## Example usage:
/// ```no-compile
/// feature! {
/// #![any(
/// feature = "process",
/// feature = "sync",
/// feature = "rt",
/// tokio_unstable
/// )]
/// /// docs
/// pub struct MyStruct {};
/// /// docs
/// pub struct AnotherStruct {};
/// }
/// ```
///
macro_rules! feature {
(
#![$meta:meta]

View File

@ -342,8 +342,13 @@ impl RuntimeMetrics {
.worker_metrics(worker)
.thread_id()
}
}
cfg_64bit_metrics! {
feature! {
#![all(
tokio_unstable,
target_has_atomic = "64"
)]
/// Returns the number of tasks spawned in this runtime since it was created.
///
/// This count starts at zero when the runtime is created and increases by one each time a task is spawned.
@ -683,6 +688,8 @@ impl RuntimeMetrics {
}
}
cfg_unstable_metrics! {
/// Renamed to [`RuntimeMetrics::global_queue_depth`]
#[deprecated = "Renamed to global_queue_depth"]
#[doc(hidden)]
@ -877,8 +884,13 @@ impl RuntimeMetrics {
pub fn poll_count_histogram_bucket_range(&self, bucket: usize) -> Range<Duration> {
self.poll_time_histogram_bucket_range(bucket)
}
}
cfg_64bit_metrics! {
feature! {
#![all(
tokio_unstable,
target_has_atomic = "64"
)]
/// Returns the number of times the given worker polled tasks with a poll
/// duration within the given bucket's range.
///
@ -992,6 +1004,7 @@ impl RuntimeMetrics {
}
}
cfg_unstable_metrics! {
/// Returns the number of tasks currently scheduled in the blocking
/// thread pool, spawned using `spawn_blocking`.
///
@ -1015,9 +1028,14 @@ impl RuntimeMetrics {
pub fn blocking_queue_depth(&self) -> usize {
self.handle.inner.blocking_queue_depth()
}
}
cfg_net! {
cfg_64bit_metrics! {
feature! {
#![all(
tokio_unstable,
target_has_atomic = "64",
feature = "net"
)]
/// Returns the number of file descriptors that have been registered with the
/// runtime's I/O driver.
///
@ -1103,5 +1121,3 @@ impl RuntimeMetrics {
}
}
}
}
}