pub struct ResourceMonitor { /* private fields */ }
Expand description
Resource monitor for tracking usage patterns
Implementations§
Source§impl ResourceMonitor
impl ResourceMonitor
Sourcepub fn new(instance_id: Option<InstanceId>) -> Self
pub fn new(instance_id: Option<InstanceId>) -> Self
Create a new resource monitor
Sourcepub fn update_memory(&mut self, current_bytes: usize)
pub fn update_memory(&mut self, current_bytes: usize)
Update memory usage
Sourcepub fn record_allocation(&mut self, _bytes: usize)
pub fn record_allocation(&mut self, _bytes: usize)
Record memory allocation
Sourcepub fn record_deallocation(&mut self, _bytes: usize)
pub fn record_deallocation(&mut self, _bytes: usize)
Record memory deallocation
Sourcepub fn update_cpu_time(&mut self, time_spent: Duration)
pub fn update_cpu_time(&mut self, time_spent: Duration)
Update CPU usage
Sourcepub fn record_function_call(&mut self)
pub fn record_function_call(&mut self)
Record function call
Sourcepub fn record_instructions(&mut self, count: u64)
pub fn record_instructions(&mut self, count: u64)
Record instructions executed
Sourcepub fn record_file_open(&mut self)
pub fn record_file_open(&mut self)
Record file operation
Sourcepub fn record_file_read(&mut self, bytes: u64)
pub fn record_file_read(&mut self, bytes: u64)
Record file read
Sourcepub fn record_file_write(&mut self, bytes: u64)
pub fn record_file_write(&mut self, bytes: u64)
Record file write
Sourcepub fn record_network_request(&mut self)
pub fn record_network_request(&mut self)
Record network request
Sourcepub fn take_snapshot(&mut self)
pub fn take_snapshot(&mut self)
Take a resource snapshot
Sourcepub fn get_detailed_usage(&self) -> DetailedResourceUsage
pub fn get_detailed_usage(&self) -> DetailedResourceUsage
Get detailed resource usage
Sourcepub fn get_current_usage(&self) -> DetailedResourceUsage
pub fn get_current_usage(&self) -> DetailedResourceUsage
Get current resource usage
Sourcepub fn check_resource_limit(
&self,
kind: &ResourceKind,
limit: u64,
) -> Option<(u64, String)>
pub fn check_resource_limit( &self, kind: &ResourceKind, limit: u64, ) -> Option<(u64, String)>
Check if resource limit is exceeded
Sourcepub fn get_utilization(&self, kind: &ResourceKind, limit: u64) -> f64
pub fn get_utilization(&self, kind: &ResourceKind, limit: u64) -> f64
Get utilization percentage for a resource
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ResourceMonitor
impl RefUnwindSafe for ResourceMonitor
impl Send for ResourceMonitor
impl Sync for ResourceMonitor
impl Unpin for ResourceMonitor
impl UnwindSafe for ResourceMonitor
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> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
Query the “status” flags for the
self
file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
Set the “status” flags for the
self
file descriptor. Read moreSource§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