pub struct Metrics { /* private fields */ }Expand description
Standard metrics for agentguard.
Implementations§
Source§impl Metrics
impl Metrics
Sourcepub fn new() -> Self
pub fn new() -> Self
Build a new metrics registry. Returns Self; wrap with
Arc::new(Metrics::new()) at the call site if shared
ownership is needed.
Sourcepub fn with_cap(cardinality_cap: usize) -> Self
pub fn with_cap(cardinality_cap: usize) -> Self
Construct a registry with a custom cardinality cap. Used in tests that want to verify the cap is enforced.
pub fn cardinality_cap(&self) -> usize
pub fn record_decision( &self, effect: &str, policy_id: &str, action: &str, tenant_id: &str, duration: Duration, )
pub fn record_delegation_mint(&self)
pub fn record_delegation_verify(&self, success: bool)
pub fn record_cache_hit(&self)
pub fn record_cache_miss(&self)
pub fn record_policy_reload(&self)
pub fn record_pdp_error(&self, fallback: &str)
Sourcepub fn render_prometheus(&self) -> String
pub fn render_prometheus(&self) -> String
Render a snapshot of all counters in Prometheus text format.
Uses std::fmt::Write to write directly into the output
String, avoiding the dozens of format! temporaries the
previous implementation allocated.
Sourcepub fn snapshot(&self) -> MetricsSnapshot
pub fn snapshot(&self) -> MetricsSnapshot
Build a snapshot of all counters for programmatic access.
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 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