#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(docsrs, allow(unused_attributes))]
#![cfg_attr(
all(tokio_unstable, feature = "rt"),
doc = r##"
### Collecting runtime metrics
**This functionality requires `tokio_unstable` and the crate feature `rt`.**
In the below example, a [`RuntimeCollector`] is constructed and used to
collect tokio runtime metrics every second.
```
use prometheus::Encoder;
#[tokio::main]
async fn main() {
// register global runtime collector
prometheus::default_registry()
.register(Box::new(
tokio_metrics_collector::default_runtime_collector(),
))
.unwrap();
// print metrics every tick
for _ in 0..5 {
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
let encoder = prometheus::TextEncoder::new();
let mut buffer = Vec::new();
encoder
.encode(&prometheus::default_registry().gather(), &mut buffer)
.unwrap();
let data = String::from_utf8(buffer.clone()).unwrap();
println!("{}", data);
}
}
```
"##
)]
mod task;
pub use task::default_collector as default_task_collector;
pub use task::TaskCollector;
pub use tokio_metrics::TaskMonitor;
macro_rules! cfg_rt {
($($item:item)*) => {
$(
#[cfg(all(tokio_unstable, feature = "rt"))]
#[cfg_attr(docsrs, doc(cfg(all(tokio_unstable, feature = "rt"))))]
$item
)*
};
}
cfg_rt! {
mod runtime;
pub use runtime::default_collector as default_runtime_collector;
pub use runtime::RuntimeCollector;
}