TaskInstrument

Trait TaskInstrument 

Source
pub trait TaskInstrument {
    // Required method
    fn with_task_instrumentation(
        self,
        task_name: String,
    ) -> InstrumentedTask<Self> 
       where Self: Sized;
}
Expand description

Helper trait for instrumenting futures that are run as asynchronous tasks.

Required Methods§

Source

fn with_task_instrumentation(self, task_name: String) -> InstrumentedTask<Self>
where Self: Sized,

Instruments the future, tracking task-specific metrics about its execution.

Whenever the resulting future is polled, two internal metrics are updated: runtime_task.poll_count is incremented by one, and runtime_task.poll_duration_seconds records the duration of the poll operation, in seconds. Both metrics are tagged with the task name provided here (as task_name:<task name>).

In general, a unique task name should be provided where possible. If multiple tasks share the same task name, they will all update the same metric, which will simply influence the resulting percentiles and make it more difficult to isolate outlier poll durations.

Implementors§

Source§

impl<F> TaskInstrument for F
where F: Future + Send + 'static,