[][src]Function metrical::gauge

pub fn gauge(name: String) -> Gauge

Create a gauge to monitor both incrementing and decrementing of a statistic

Example

use metrical::gauge;
use std::thread::JoinHandle;

struct Threader{
    threads: Vec<JoinHandle<()>>
}

impl Threader {
    pub fn add_resource(&mut self) {
        let mut gauge = gauge("NumThreadsInUse".to_owned());
        gauge.increment(1);

        self.threads.push(std::thread::spawn(||
            println!("This does nothing...")
        ));
    }

    pub fn terminate_resource(&mut self) {
        let mut gauge = gauge("NumThreadsInUse".to_owned());
        gauge.decrement(1);

        self.threads.pop().map(|thread| thread.join());
    }
}