Skip to content

Commit bce4ac3

Browse files
committed
metrics: stabilize worker_count to start the process of metric stabilization
This PR also introduces a `metrics` feature. Refs: tokio-rs#6546
1 parent 6fcd9c0 commit bce4ac3

File tree

11 files changed

+856
-835
lines changed

11 files changed

+856
-835
lines changed

tokio/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ full = [
3131
"io-util",
3232
"io-std",
3333
"macros",
34+
"metrics",
3435
"net",
3536
"parking_lot",
3637
"process",
@@ -46,6 +47,7 @@ io-util = ["bytes"]
4647
# stdin, stdout, stderr
4748
io-std = []
4849
macros = ["tokio-macros"]
50+
metrics = []
4951
net = [
5052
"libc",
5153
"mio/os-poll",

tokio/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ compile_error!("The `tokio_taskdump` feature requires `--cfg tokio_unstable`.");
471471

472472
#[cfg(all(
473473
tokio_taskdump,
474+
not(doc),
474475
not(all(
475476
target_os = "linux",
476477
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")

tokio/src/macros/cfg.rs

+11
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,17 @@ macro_rules! cfg_macros {
215215
}
216216
}
217217

218+
macro_rules! cfg_stable_metrics {
219+
($($item:item)*) => {
220+
$(
221+
#[cfg(not(loom))]
222+
#[cfg(feature = "metrics")]
223+
#[cfg_attr(docsrs, doc(cfg(feature = "metrics")))]
224+
$item
225+
)*
226+
}
227+
}
228+
218229
macro_rules! cfg_metrics {
219230
($($item:item)*) => {
220231
$(

tokio/src/runtime/handle.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -395,15 +395,15 @@ impl Handle {
395395
}
396396
}
397397

398-
cfg_metrics! {
398+
cfg_rt! {
399399
use crate::runtime::RuntimeMetrics;
400+
}
400401

401-
impl Handle {
402-
/// Returns a view that lets you get information about how the runtime
403-
/// is performing.
404-
pub fn metrics(&self) -> RuntimeMetrics {
405-
RuntimeMetrics::new(self.clone())
406-
}
402+
impl Handle {
403+
/// Returns a view that lets you get information about how the runtime
404+
/// is performing.
405+
pub fn metrics(&self) -> RuntimeMetrics {
406+
RuntimeMetrics::new(self.clone())
407407
}
408408
}
409409

tokio/src/runtime/metrics/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
//! [unstable]: crate#unstable-features
99
#![allow(clippy::module_inception)]
1010

11+
mod runtime;
12+
pub use runtime::RuntimeMetrics;
13+
1114
cfg_metrics! {
1215
mod batch;
1316
pub(crate) use batch::MetricsBatch;
@@ -17,10 +20,6 @@ cfg_metrics! {
1720
#[allow(unreachable_pub)] // rust-lang/rust#57411
1821
pub use histogram::HistogramScale;
1922

20-
mod runtime;
21-
#[allow(unreachable_pub)] // rust-lang/rust#57411
22-
pub use runtime::RuntimeMetrics;
23-
2423
mod scheduler;
2524
pub(crate) use scheduler::SchedulerMetrics;
2625

0 commit comments

Comments
 (0)