ff_observability/shim.rs
1//! No-op shim used when the `enabled` feature is OFF.
2//!
3//! Every method here is a zero-sized no-op so call sites compile
4//! identically under both features. The `render` method returns an
5//! empty string so a caller that forgot to gate a route mount cannot
6//! emit misleading /metrics output (it will serve empty text, not
7//! fabricated data).
8
9use std::time::Duration;
10
11/// Zero-sized no-op registry. Identical public shape to the real
12/// implementation (see `real.rs`) so call sites don't know which
13/// backend they're hitting.
14#[derive(Clone, Default)]
15pub struct Metrics;
16
17impl Metrics {
18 /// Construct a disabled (no-op) metrics registry. The `enabled`-OFF
19 /// configuration has no fallible initialization, so this returns
20 /// `Self` directly (not `Result<Self, _>`) to keep call sites
21 /// feature-symmetric.
22 pub fn new() -> Self {
23 Self
24 }
25
26 /// Render the Prometheus text exposition. Empty when disabled.
27 pub fn render(&self) -> String {
28 String::new()
29 }
30
31 // ── HTTP ──
32
33 pub fn record_http_request(
34 &self,
35 _method: &str,
36 _path: &str,
37 _status: u16,
38 _elapsed: Duration,
39 ) {
40 }
41
42 // ── Scanner ──
43
44 pub fn record_scanner_cycle(&self, _scanner: &'static str, _elapsed: Duration) {}
45
46 // ── Cancel backlog (gauge) ──
47
48 pub fn set_cancel_backlog_depth(&self, _depth: u64) {}
49
50 // ── Claim ──
51
52 pub fn record_claim_from_grant(&self, _lane: &str, _elapsed: Duration) {}
53
54 // ── Lease renewal ──
55
56 pub fn inc_lease_renewal(&self, _outcome: &'static str) {}
57
58 // ── Attempt terminal outcome ──
59
60 pub fn inc_attempt_outcome(&self, _lane: &str, _outcome: super::AttemptOutcome) {}
61
62 // ── Worker-at-capacity ──
63
64 pub fn inc_worker_at_capacity(&self) {}
65
66 // ── Budget / quota admission ──
67
68 pub fn inc_budget_hit(&self, _dimension: &str) {}
69 pub fn inc_quota_hit(&self, _reason: &'static str) {}
70
71 // ── RFC-016 Stage A: edge-group policy ──
72
73 pub fn inc_edge_group_policy(&self, _policy: &'static str) {}
74
75 // ── RFC-016 Stage C: sibling-cancel dispatcher ──
76
77 pub fn inc_sibling_cancel_dispatched(&self, _reason: &'static str) {}
78 pub fn inc_sibling_cancel_disposition(&self, _disposition: &'static str) {}
79
80 // ── RFC-016 Stage D: sibling-cancel reconciler ──
81
82 pub fn inc_sibling_cancel_reconcile(&self, _action: &'static str) {}
83
84 // ── RFC-017 Stage B: shutdown_prepare timeout ──
85
86 pub fn inc_shutdown_timeout(&self) {}
87
88 // ── RFC-017 Stage D1 (§8): legacy waitpoint_token audit ──
89
90 pub fn inc_pending_waitpoint_legacy_token(&self) {}
91
92 // ── RFC-017 §9.0 dev-override ──
93
94 pub fn inc_backend_unready_boot(&self, _backend: &'static str, _stage: &'static str) {}
95}