pub trait HttpMetricsHook:
Clone
+ Send
+ Sync
+ 'static {
// Required methods
fn on_request(&self, method: &Method, route: Option<&str>);
fn on_response(
&self,
method: &Method,
route: Option<&str>,
status: StatusCode,
latency: Duration,
);
// Provided method
fn on_error(
&self,
_method: &Method,
_route: Option<&str>,
_latency: Duration,
) { ... }
}Expand description
Backend-neutral hook for recording HTTP request metrics.
Implement this trait to bridge Nidus’ middleware lifecycle into a concrete
metrics backend. Hooks are called in-process: one on_request before the
inner service, one on_response after a response, or on_error if the inner
service returns an error before producing a response.
Required Methods§
Sourcefn on_request(&self, method: &Method, route: Option<&str>)
fn on_request(&self, method: &Method, route: Option<&str>)
Records that a request entered the service.
Sourcefn on_response(
&self,
method: &Method,
route: Option<&str>,
status: StatusCode,
latency: Duration,
)
fn on_response( &self, method: &Method, route: Option<&str>, status: StatusCode, latency: Duration, )
Records that a response left the service.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".