[][src]Trait tower_load::Instrument

pub trait Instrument<H, V>: Clone {
    type Output;
    fn instrument(&self, handle: H, value: V) -> Self::Output;
}

Attaches I-typed instruments to V typed values.

This utility allows load metrics to have a protocol-agnostic means to track streams past their initial response future. For example, if V represents an HTTP response type, an implementation could add H-typed handles to each response's extensions to detect when the response is dropped.

Handles are intended to be RAII guards that primarily implement Drop and update load metric state as they are dropped.

A base impl<H, V> Instrument<H, V> for NoInstrument is provided to drop the handle immediately. This is appropriate when a response is discrete and cannot comprise multiple messages.

In many cases, the Output type is simply V. However, Instrument may alter the type in order to instrument it appropriately. For example, an HTTP Instrument may modify the body type: so an Instrument that takes values of type http::Response<A> may output values of type http::Response<B>.

Associated Types

type Output

The instrumented value type.

Loading content...

Required methods

fn instrument(&self, handle: H, value: V) -> Self::Output

Attaches an H-typed handle to a V-typed value.

Loading content...

Implementors

impl<H, V> Instrument<H, V> for NoInstrument[src]

type Output = V

Loading content...