oauth2_broker/obs/
metrics.rs1use crate::obs::{FlowKind, FlowOutcome};
3
4pub fn record_flow_outcome(kind: FlowKind, outcome: FlowOutcome) {
6 #[cfg(feature = "metrics")]
7 {
8 metrics::counter!(
9 "oauth2_broker_flow_total",
10 "flow" => kind.as_str(),
11 "outcome" => outcome.as_str()
12 )
13 .increment(1);
14 }
15
16 #[cfg(not(feature = "metrics"))]
17 {
18 let _ = (kind, outcome);
19 }
20}
21
22#[cfg(test)]
23mod tests {
24 use super::*;
26
27 #[test]
28 fn record_flow_outcome_noop_without_metrics() {
29 record_flow_outcome(FlowKind::AuthorizationCode, FlowOutcome::Failure);
30 }
31}