pub struct AuthMetrics {
pub total_auth_attempts: u64,
pub successful_authentications: u64,
pub failed_authentications: u64,
pub tokens_issued: u64,
pub tokens_refreshed: u64,
pub sessions_revoked: u64,
}Expand description
In-process counters for authentication operations.
These counters are for lightweight observability within a single process.
For production monitoring, export these values to a metrics system such as
Prometheus. All fields are plain u64; thread-safe mutation requires an
outer Mutex or RwLock.
Fields§
§total_auth_attempts: u64Total number of authentication attempts (successful + failed).
successful_authentications: u64Number of authentication attempts that succeeded.
failed_authentications: u64Number of authentication attempts that failed.
tokens_issued: u64Number of access tokens issued since startup.
tokens_refreshed: u64Number of access tokens refreshed since startup.
sessions_revoked: u64Number of sessions explicitly revoked since startup.
Implementations§
Source§impl AuthMetrics
impl AuthMetrics
Sourcepub const fn record_attempt(&mut self)
pub const fn record_attempt(&mut self)
Increment the total authentication attempts counter.
Sourcepub const fn record_success(&mut self)
pub const fn record_success(&mut self)
Increment the successful authentications counter.
Sourcepub const fn record_failure(&mut self)
pub const fn record_failure(&mut self)
Increment the failed authentications counter.
Sourcepub const fn record_token_issued(&mut self)
pub const fn record_token_issued(&mut self)
Increment the tokens issued counter.
Sourcepub const fn record_token_refreshed(&mut self)
pub const fn record_token_refreshed(&mut self)
Increment the tokens refreshed counter.
Sourcepub const fn record_session_revoked(&mut self)
pub const fn record_session_revoked(&mut self)
Increment the sessions revoked counter.
Sourcepub fn success_rate(&self) -> f64
pub fn success_rate(&self) -> f64
Return the success rate as a percentage (0–100).
Returns 0.0 when no attempts have been recorded yet.
Trait Implementations§
Source§impl Clone for AuthMetrics
impl Clone for AuthMetrics
Source§fn clone(&self) -> AuthMetrics
fn clone(&self) -> AuthMetrics
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AuthMetrics
impl Debug for AuthMetrics
Auto Trait Implementations§
impl Freeze for AuthMetrics
impl RefUnwindSafe for AuthMetrics
impl Send for AuthMetrics
impl Sync for AuthMetrics
impl Unpin for AuthMetrics
impl UnsafeUnpin for AuthMetrics
impl UnwindSafe for AuthMetrics
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more