pub struct TracingLayer { /* private fields */ }Expand description
Middleware layer that creates tracing spans for requests
This layer creates a span for each request containing:
- HTTP method
- Request path
- Request ID (if RequestIdLayer is applied)
- Response status code
- Request duration
- Any custom fields configured via
with_field()
§Example
ⓘ
use rustapi_core::middleware::TracingLayer;
RustApi::new()
.layer(TracingLayer::new()
.with_field("service", "my-api")
.with_field("version", "1.0.0"))
.route("/", get(handler))Implementations§
Source§impl TracingLayer
impl TracingLayer
Sourcepub fn with_level(level: Level) -> Self
pub fn with_level(level: Level) -> Self
Create a TracingLayer with a specific log level
Trait Implementations§
Source§impl Clone for TracingLayer
impl Clone for TracingLayer
Source§fn clone(&self) -> TracingLayer
fn clone(&self) -> TracingLayer
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 Default for TracingLayer
impl Default for TracingLayer
Source§impl MiddlewareLayer for TracingLayer
impl MiddlewareLayer for TracingLayer
Auto Trait Implementations§
impl Freeze for TracingLayer
impl RefUnwindSafe for TracingLayer
impl Send for TracingLayer
impl Sync for TracingLayer
impl Unpin for TracingLayer
impl UnwindSafe for TracingLayer
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