[−][src]Struct replicante_util_iron::MetricsMiddleware
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]
prefix: S
) -> (HistogramVec, CounterVec, CounterVec)
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]
duration: HistogramVec,
errors: CounterVec,
requests: CounterVec,
logger: Logger
) -> MetricsMiddleware
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
impl Send for MetricsMiddleware
impl Sync for MetricsMiddleware
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Typeable for T where
T: Any,
T: Any,
impl<T> UnsafeAny for T where
T: Any,
T: Any,
impl<T> Erased for T
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,