oauth2_broker/obs/
metrics.rs

1// self
2use crate::obs::{FlowKind, FlowOutcome};
3
4/// Records a flow outcome via the global metrics recorder (when enabled).
5pub 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	// self
25	use super::*;
26
27	#[test]
28	fn record_flow_outcome_noop_without_metrics() {
29		record_flow_outcome(FlowKind::AuthorizationCode, FlowOutcome::Failure);
30	}
31}