drogue_client/metrics/
ext.rs

1use super::{AsPassFailError, PassFailError};
2use prometheus::IntGaugeVec;
3
4pub trait PassFailErrorExt {
5    fn record_outcome(self, gauge: &IntGaugeVec) -> Self;
6}
7
8/// Record outcome to a gauge with the "outcome" label as first label.
9impl<T: AsPassFailError> PassFailErrorExt for T {
10    fn record_outcome(self, gauge: &IntGaugeVec) -> Self {
11        match self.as_pass_fail_error() {
12            PassFailError::Pass => gauge.with_label_values(&["pass"]).inc(),
13            PassFailError::Fail => gauge.with_label_values(&["fail"]).inc(),
14            PassFailError::Error => gauge.with_label_values(&["error"]).inc(),
15        }
16        self
17    }
18}