Trait FutureMeter

Source
pub trait FutureMeter<'a>: Sized {
    // Provided methods
    fn meter(self, name: &'static str) -> Meter<Self> { ... }
    fn meter_ms(self, name: &'static str, log_interval_ms: u64) -> Meter<Self> { ... }
    fn meter_with_logging(
        self,
        name: &'static str,
        log_interval: Duration,
    ) -> Meter<Self> { ... }
    fn meter_root(self, name: &'static str) -> MeterRoot<Self> { ... }
    fn meter_root_ms(
        self,
        name: &'static str,
        log_interval_ms: u64,
    ) -> MeterRoot<Self> { ... }
    fn meter_root_with_logging(
        self,
        name: &'static str,
        log_interval: Duration,
    ) -> MeterRoot<Self> { ... }
}
Expand description

Allows for measuring execution time for each future individually and within a call stack

We don’t expose these metrics yet, but will in the future

This trait should be extracted into it’s own library or we need to migrate to a library that provides something similar

Provided Methods§

Source

fn meter(self, name: &'static str) -> Meter<Self>

Add an entry in the call stack for this future

Source

fn meter_ms(self, name: &'static str, log_interval_ms: u64) -> Meter<Self>

Similar to meter_with_logging but specifies interval in milliseconds

Source

fn meter_with_logging( self, name: &'static str, log_interval: Duration, ) -> Meter<Self>

Add an entry in the call stack for this future and log when it has been running for more than log_interval and when it finishes after log_interval

Source

fn meter_root(self, name: &'static str) -> MeterRoot<Self>

Like meter but creates a root that other futures can use

Multiple roots are ok to use, but creating a new one will disassociate the existing call stack

This needs to be used for all futures that are at the base of the call stack that will be measured.

Source

fn meter_root_ms( self, name: &'static str, log_interval_ms: u64, ) -> MeterRoot<Self>

Like meter_ms but creates a root that other futures can use

Multiple roots are ok to use, but creating a new one will disassociate the existing call stack

This needs to be used for all futures that are at the base of the call stack that will be measured.

Source

fn meter_root_with_logging( self, name: &'static str, log_interval: Duration, ) -> MeterRoot<Self>

Like meter_with_logging but creates a root that other futures can use

Multiple roots are ok to use, but creating a new one will disassociate the existing call stack

This needs to be used for all futures that are at the base of the call stack that will be measured.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a, F: Future + Sized> FutureMeter<'a> for F