pub trait SpanExt {
// Required methods
fn from_request(req: &Request, opt_in: bool) -> Self;
fn add_header_fields(&self, headers: &HeaderMap);
fn finalize_with_response(&self, response: &mut Response);
fn finalize_with_error<E>(&self, error: &mut E)
where E: Error;
// Provided method
fn finalize<E>(&self, result: &mut Result<Response, E>)
where E: Error { ... }
}
Expand description
This trait provides various helper functions to create a [Span
] out of
an HTTP [Request
].
Required Methods§
Sourcefn from_request(req: &Request, opt_in: bool) -> Self
fn from_request(req: &Request, opt_in: bool) -> Self
Create a span according to the semantic conventions for HTTP spans from
an Axum [Request
].
The individual fields are defined in this specification. Some of them are:
http.request.method
http.response.status_code
network.protocol.version
Setting the opt_in
parameter to true
enables various fields marked
as opt-in by the specification. This will require more computing power
and will increase the latency.
Sourcefn add_header_fields(&self, headers: &HeaderMap)
fn add_header_fields(&self, headers: &HeaderMap)
Adds HTTP request headers to the span as a http.request.header.<key>
field.
NOTE: This is currently not supported, because [tracing
] doesn’t
support recording dynamic fields.
Sourcefn finalize_with_response(&self, response: &mut Response)
fn finalize_with_response(&self, response: &mut Response)
Finalize the [Span
] with an Axum [Response
].
Sourcefn finalize_with_error<E>(&self, error: &mut E)where
E: Error,
fn finalize_with_error<E>(&self, error: &mut E)where
E: Error,
Finalize the [Span
] with an error.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.