pub struct Metrics { /* private fields */ }Expand description
Process-wide metric registry. All methods take &self and use relaxed atomics — metrics
are monotonic counters/observations where exact inter-thread ordering doesn’t matter.
Implementations§
Source§impl Metrics
impl Metrics
pub fn new() -> Self
Sourcepub fn record_request(&self, outcome: &str)
pub fn record_request(&self, outcome: &str)
Count one finished request under its outcome label.
Sourcepub fn observe_latency(&self, elapsed: Duration)
pub fn observe_latency(&self, elapsed: Duration)
Observe a request’s end-to-end latency into the histogram.
Sourcepub fn record_ratelimit_hit(&self, scope: &str)
pub fn record_ratelimit_hit(&self, scope: &str)
Count a rate-limit rejection by which limiter scope tripped (ip/route/key).
Sourcepub fn record_waf_hit(&self, class: &str)
pub fn record_waf_hit(&self, class: &str)
Count one WAF rule match by rule class (sqli/xss/path_traversal/custom).
Recorded for both report-only and blocking modes — so a report-first rollout is
visible — while a blocked request is additionally counted under the forbidden
request outcome.
Sourcepub fn record_csp_report(&self)
pub fn record_csp_report(&self)
Count one received CSP violation report.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Metrics
impl RefUnwindSafe for Metrics
impl Send for Metrics
impl Sync for Metrics
impl Unpin for Metrics
impl UnsafeUnpin for Metrics
impl UnwindSafe for Metrics
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more