drogue-client 0.11.1

Clients for the Drogue IoT Cloud APIs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use super::{AsPassFailError, PassFailError};
use prometheus::IntGaugeVec;

pub trait PassFailErrorExt {
    fn record_outcome(self, gauge: &IntGaugeVec) -> Self;
}

/// Record outcome to a gauge with the "outcome" label as first label.
impl<T: AsPassFailError> PassFailErrorExt for T {
    fn record_outcome(self, gauge: &IntGaugeVec) -> Self {
        match self.as_pass_fail_error() {
            PassFailError::Pass => gauge.with_label_values(&["pass"]).inc(),
            PassFailError::Fail => gauge.with_label_values(&["fail"]).inc(),
            PassFailError::Error => gauge.with_label_values(&["error"]).inc(),
        }
        self
    }
}