pub struct Procfs<B: Backend = ProcfsBackend> { /* private fields */ }Expand description
Procfs-based metric source.
Reads memory and I/O metrics from /proc for a target process and its
entire child hierarchy, as well as system-wide memory metrics.
§Example
use joule_profiler_source_procfs::{Procfs, config::ProcfsConfig};
let source = Procfs::new(ProcfsConfig::default()).unwrap();Implementations§
Source§impl Procfs
impl Procfs
Sourcepub fn new(config: ProcfsConfig) -> Result<Self, ProcfsError>
pub fn new(config: ProcfsConfig) -> Result<Self, ProcfsError>
Creates a new Procfs source from the given configuration.
Reads MemTotal from /proc/meminfo at construction time.
Trait Implementations§
Source§impl<B: Backend> MetricReader for Procfs<B>
impl<B: Backend> MetricReader for Procfs<B>
Source§async fn init(&mut self, pid: i32) -> Result<(), ProcfsError>
async fn init(&mut self, pid: i32) -> Result<(), ProcfsError>
Initializes the source to pid and starts the background poller if a poll_interval is configured.
Source§async fn join(&mut self) -> Result<(), ProcfsError>
async fn join(&mut self) -> Result<(), ProcfsError>
Aborts the background poller if still running, or propagates its error if it already finished.
Source§async fn measure(&mut self) -> Result<(), ProcfsError>
async fn measure(&mut self) -> Result<(), ProcfsError>
Takes a single snapshot of process and global counters and updates them.
If the process is not found, an empty snapshot is used.
Source§async fn retrieve(&mut self) -> Result<Self::Type, ProcfsError>
async fn retrieve(&mut self) -> Result<Self::Type, ProcfsError>
Returns the accumulated counters for the current phase and resets them.
Source§type Error = ProcfsError
type Error = ProcfsError
Error type produced by the reader.
Source§type Config = ProcfsConfig
type Config = ProcfsConfig
Config type for configuring the source.
fn from_config(config: ProcfsConfig) -> Result<Self, ProcfsError>
Source§async fn pre_init(&mut self) -> Result<(), ProcfsError>
async fn pre_init(&mut self) -> Result<(), ProcfsError>
Pre-initialize the source, called before the process is spawned.
Source§fn get_sensors(&self) -> Result<Sensors, ProcfsError>
fn get_sensors(&self) -> Result<Sensors, ProcfsError>
Return all sensors available from this reader.
Source§fn to_metrics(&self, counters: Self::Type) -> Result<Metrics, ProcfsError>
fn to_metrics(&self, counters: Self::Type) -> Result<Metrics, ProcfsError>
Convert the metric reader data to metrics.
Auto Trait Implementations§
impl<B> Freeze for Procfs<B>
impl<B> RefUnwindSafe for Procfs<B>where
B: RefUnwindSafe,
impl<B> Send for Procfs<B>
impl<B> Sync for Procfs<B>
impl<B> Unpin for Procfs<B>
impl<B> UnsafeUnpin for Procfs<B>
impl<B> UnwindSafe for Procfs<B>where
B: RefUnwindSafe,
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