[][src]Struct replicante_util_iron::MetricsMiddleware

pub struct MetricsMiddleware { /* fields omitted */ }

An Iron middlewere to collect metrics about endpoints.

This middlewere collects the following information:

  • The duration of endpoints as an histogram.
  • The number of requests that return an error.
  • The count of responses by method, path, HTTP status code.

Methods

impl MetricsMiddleware[src]

pub fn metrics<S: Into<String>>(
    prefix: S
) -> (HistogramVec, CounterVec, CounterVec)
[src]

Generates the metrics needed my the middleware.

The three metrics returned (duration, erorrs, requests) are configured with the minimum requirements to be passed to MetricsMiddleware::new.

Metric names are prefixed with the given prefix and have the following attributes:

  • Name: <PEFIX>_endpoint_duration. Description: Duration (in seconds) of HTTP endpoints. Static labels: none. Dynamic labels: method, path.

  • Name: <PEFIX>_endpoint_errors. Description: Number of errors encountered while handling requests. Static labels: none. Dynamic labels: method, path.

  • Name: <PEFIX>_endpoint_requests. Description: Unable to configure requests counter. Static labels: none. Dynamic labels: method, path, status.

pub fn new(
    duration: HistogramVec,
    errors: CounterVec,
    requests: CounterVec,
    logger: Logger
) -> MetricsMiddleware
[src]

Constructs a new MetricsMiddleware to record metrics about handlers.

The metrics to record observations in are passed to this method and must match the below requirements:

  • The duration HistogramVec must have exactly two variable labels: ["method", "path"].
  • The errors CounterVec must have exactly two variable labels: ["method", "path"].
  • The requests HistogramVec must have exactly three variable labels: ["method", "path", "status"].
  • None of the variable labels above can be constant labels.

Panics

This method validates the given metrics against the requirements and panics if any is not met.

pub fn into_middleware(self) -> (MetricsBefore, MetricsAfter)[src]

Converts the middlewere into Iron's BeforeMiddleware and AfterMiddleware.

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Typeable for T where
    T: Any

fn get_type(&self) -> TypeId

Get the TypeId of this object.

impl<T> UnsafeAny for T where
    T: Any

impl<T> Erased for T

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

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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

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