pub struct OtelLayer;Expand description
Middleware that creates an HTTP server span for each request.
- Reads W3C
traceparentfrom the request to continue an existing trace. - Creates a new trace when no
traceparentis present. - Stores the active span in thread-local storage so downstream middleware
(e.g.
crate::proxy::ReverseProxy) can propagate it. - Records the span on the way out with
http.method,http.target, andhttp.status_codeattributes.
Requires setup or setup_from_env to be called at startup. Without
initialisation the layer is a no-op passthrough.
Trait Implementations§
Source§impl Middleware for OtelLayer
impl Middleware for OtelLayer
Source§fn runs_inline(&self, _request: &Request, _connection: &ConnectionInfo) -> bool
fn runs_inline(&self, _request: &Request, _connection: &ConnectionInfo) -> bool
Spans are recorded in memory (export runs on its own thread): safe on the event loop.
Source§fn accepts_streamed_body(
&self,
_request: &Request,
_connection: &ConnectionInfo,
) -> bool
fn accepts_streamed_body( &self, _request: &Request, _connection: &ConnectionInfo, ) -> bool
Headers only: a streamed body passes through untouched.
fn handle( &self, request: &Request, connection: &ConnectionInfo, next: &dyn Application, ) -> Result<Response, String>
Source§fn is_passthrough(
&self,
_request: &Request,
_connection: &ConnectionInfo,
) -> bool
fn is_passthrough( &self, _request: &Request, _connection: &ConnectionInfo, ) -> bool
true when handle would do nothing for request but call next
(e.g. a rate limit that isn’t configured). A WithMiddleware stack
offers the inner application’s execute_async only if every layer
passes the request through. Default false.Source§fn answers_streamed_body(
&self,
_request: &Request,
_connection: &ConnectionInfo,
) -> bool
fn answers_streamed_body( &self, _request: &Request, _connection: &ConnectionInfo, ) -> bool
true when this layer answers request itself — it doesn’t call
next — and reads its body as a stream (a proxy forwarding it as it
arrives). The body is then streamed whatever the layers after it and
the application would say. Requires accepts_streamed_body. Since
18.3.0.Auto Trait Implementations§
impl Freeze for OtelLayer
impl RefUnwindSafe for OtelLayer
impl Send for OtelLayer
impl Sync for OtelLayer
impl Unpin for OtelLayer
impl UnsafeUnpin for OtelLayer
impl UnwindSafe for OtelLayer
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