pub struct TimingMetricsMiddleware { /* private fields */ }Expand description
Middleware that collects and exposes timing metrics.
This middleware:
- Records the request start time
- Injects
TimingMetricsinto request extensions for handlers to use - Adds timing headers to the response
§Example
ⓘ
let timing = TimingMetricsMiddleware::new();
// Or with custom config:
let timing = TimingMetricsMiddleware::with_config(
TimingMetricsConfig::production()
);
middleware_stack.push(timing);Implementations§
Source§impl TimingMetricsMiddleware
impl TimingMetricsMiddleware
Sourcepub fn with_config(config: TimingMetricsConfig) -> Self
pub fn with_config(config: TimingMetricsConfig) -> Self
Create with a custom configuration.
Sourcepub fn production() -> Self
pub fn production() -> Self
Create a production-safe instance (minimal headers).
Sourcepub fn development() -> Self
pub fn development() -> Self
Create a development instance (all timing info exposed).
Trait Implementations§
Source§impl Clone for TimingMetricsMiddleware
impl Clone for TimingMetricsMiddleware
Source§fn clone(&self) -> TimingMetricsMiddleware
fn clone(&self) -> TimingMetricsMiddleware
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TimingMetricsMiddleware
impl Debug for TimingMetricsMiddleware
Source§impl Default for TimingMetricsMiddleware
impl Default for TimingMetricsMiddleware
Source§impl Middleware for TimingMetricsMiddleware
impl Middleware for TimingMetricsMiddleware
Source§fn before<'a>(
&'a self,
_ctx: &'a RequestContext,
req: &'a mut Request,
) -> BoxFuture<'a, ControlFlow>
fn before<'a>( &'a self, _ctx: &'a RequestContext, req: &'a mut Request, ) -> BoxFuture<'a, ControlFlow>
Called before the handler executes. Read more
Auto Trait Implementations§
impl Freeze for TimingMetricsMiddleware
impl RefUnwindSafe for TimingMetricsMiddleware
impl Send for TimingMetricsMiddleware
impl Sync for TimingMetricsMiddleware
impl Unpin for TimingMetricsMiddleware
impl UnwindSafe for TimingMetricsMiddleware
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).