pub struct LockContentionMetrics {
pub resource_id: ResourceId,
pub name: String,
pub acquire_attempts: u64,
pub successful_acquisitions: u64,
pub contention_count: u64,
pub total_wait_time: Duration,
pub avg_wait_time: Duration,
pub max_wait_time: Duration,
pub waiting_tasks: Vec<TaskId>,
pub contention_rate: f64,
}Expand description
Lock contention metrics for a specific resource
Fields§
§resource_id: ResourceIdResource ID
name: StringResource name
acquire_attempts: u64Number of acquire attempts
successful_acquisitions: u64Number of successful acquisitions
contention_count: u64Number of times tasks had to wait
total_wait_time: DurationTotal time spent waiting for this lock
avg_wait_time: DurationAverage wait time per contention
max_wait_time: DurationMaximum wait time observed
waiting_tasks: Vec<TaskId>Tasks that waited for this resource
contention_rate: f64Contention rate (contentions / acquisitions)
Implementations§
Source§impl LockContentionMetrics
impl LockContentionMetrics
Sourcepub fn new(resource_id: ResourceId, name: String) -> Self
pub fn new(resource_id: ResourceId, name: String) -> Self
Create new lock contention metrics
Sourcepub fn record_wait(&mut self, wait_time: Duration, task_id: TaskId)
pub fn record_wait(&mut self, wait_time: Duration, task_id: TaskId)
Record a wait event
Sourcepub fn record_acquisition(&mut self)
pub fn record_acquisition(&mut self)
Record an acquisition
Sourcepub fn record_attempt(&mut self)
pub fn record_attempt(&mut self)
Record an acquire attempt
Sourcepub fn is_highly_contended(&self, threshold: f64) -> bool
pub fn is_highly_contended(&self, threshold: f64) -> bool
Check if this lock is highly contended
Trait Implementations§
Source§impl Clone for LockContentionMetrics
impl Clone for LockContentionMetrics
Source§fn clone(&self) -> LockContentionMetrics
fn clone(&self) -> LockContentionMetrics
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LockContentionMetrics
impl Debug for LockContentionMetrics
Source§impl<'de> Deserialize<'de> for LockContentionMetrics
impl<'de> Deserialize<'de> for LockContentionMetrics
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for LockContentionMetrics
impl RefUnwindSafe for LockContentionMetrics
impl Send for LockContentionMetrics
impl Sync for LockContentionMetrics
impl Unpin for LockContentionMetrics
impl UnwindSafe for LockContentionMetrics
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
Converts
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>
Converts
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