Skip to main content

Procfs

Struct Procfs 

Source
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

Source

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: Debug + Backend> Debug for Procfs<B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<B: Backend> MetricReader for Procfs<B>

Source§

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>

Aborts the background poller if still running, or propagates its error if it already finished.

Source§

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>

Returns the accumulated counters for the current phase and resets them.

Source§

type Type = Counters

Type of metrics returned by the reader.
Source§

type Error = ProcfsError

Error type produced by the reader.
Source§

type Config = ProcfsConfig

Config type for configuring the source.
Source§

fn from_config(config: ProcfsConfig) -> Result<Self, ProcfsError>

Source§

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>

Return all sensors available from this reader.
Source§

fn to_metrics(&self, counters: Self::Type) -> Result<Metrics, ProcfsError>

Convert the metric reader data to metrics.
Source§

fn get_name() -> &'static str

Get the name of the metric source.
Source§

fn get_id() -> &'static str

Get the id of the metric source.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MetricReaderTypeBound for T
where T: Send,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.