pub struct MetricsMiddleware { /* private fields */ }Expand description
Middleware that collects query metrics.
§Example
ⓘ
use prax_query::middleware::{MetricsMiddleware, InMemoryMetricsCollector};
let collector = Arc::new(InMemoryMetricsCollector::new());
let metrics = MetricsMiddleware::new(collector.clone());
// Use middleware...
// Get metrics
let stats = collector.get_metrics();
println!("Total queries: {}", stats.total_queries);
println!("Avg time: {}us", stats.avg_time_us);Implementations§
Trait Implementations§
Source§impl Middleware for MetricsMiddleware
impl Middleware for MetricsMiddleware
Source§fn handle<'a>(
&'a self,
ctx: QueryContext,
next: Next<'a>,
) -> BoxFuture<'a, MiddlewareResult<QueryResponse>>
fn handle<'a>( &'a self, ctx: QueryContext, next: Next<'a>, ) -> BoxFuture<'a, MiddlewareResult<QueryResponse>>
Handle a query, optionally calling the next handler.
Auto Trait Implementations§
impl Freeze for MetricsMiddleware
impl !RefUnwindSafe for MetricsMiddleware
impl Send for MetricsMiddleware
impl Sync for MetricsMiddleware
impl Unpin for MetricsMiddleware
impl !UnwindSafe for MetricsMiddleware
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