1use lazy_static::lazy_static;
21use prometheus::{
22 Registry, Error as PrometheusError,
23 core::{ AtomicU64, GenericGauge, GenericCounter },
24};
25
26#[cfg(feature = "metered")]
27use prometheus::{core::GenericCounterVec, Opts};
28
29
30lazy_static! {
31 pub static ref TOKIO_THREADS_TOTAL: GenericCounter<AtomicU64> = GenericCounter::new(
32 "tokio_threads_total", "Total number of threads created"
33 ).expect("Creating of statics doesn't fail. qed");
34
35 pub static ref TOKIO_THREADS_ALIVE: GenericGauge<AtomicU64> = GenericGauge::new(
36 "tokio_threads_alive", "Number of threads alive right now"
37 ).expect("Creating of statics doesn't fail. qed");
38}
39
40#[cfg(feature = "metered")]
41lazy_static! {
42 pub static ref UNBOUNDED_CHANNELS_COUNTER : GenericCounterVec<AtomicU64> = GenericCounterVec::new(
43 Opts::new("unbounded_channel_len", "Items in each mpsc::unbounded instance"),
44 &["entity", "action"] ).expect("Creating of statics doesn't fail. qed");
46
47}
48
49
50pub fn register_globals(registry: &Registry) -> Result<(), PrometheusError> {
52 registry.register(Box::new(TOKIO_THREADS_ALIVE.clone()))?;
53 registry.register(Box::new(TOKIO_THREADS_TOTAL.clone()))?;
54
55 #[cfg(feature = "metered")]
56 registry.register(Box::new(UNBOUNDED_CHANNELS_COUNTER.clone()))?;
57
58 Ok(())
59}