Expand description
Tower tracing middleware to annotate every HTTP request with tracing’s span.
§Example
Below is illustration of how to initialize request layer for passing into your service
use std::net::IpAddr;
use tower_http_tracing::HttpRequestLayer;
//Logic to extract client ip has to be written by user
//You can use utilities in separate crate to design this logic:
//https://docs.rs/http-ip/latest/http_ip/
fn extract_client_ip(_parts: &http::request::Parts) -> Option<IpAddr> {
None
}
tower_http_tracing::make_request_spanner!(make_my_request_span("my_request", tracing::Level::INFO));
let layer = HttpRequestLayer::new(make_my_request_span).with_extract_client_ip(extract_client_ip)
.with_inspect_headers(&[&http::header::FORWARDED]);
//Use above layer in your serviceRe-exports§
pub use tracing;
Macros§
- make_
request_ spanner - Declares
fnfunction compatible withMakeSpanusing provided parameters
Structs§
- Http
Request Layer - Tower layer
- Http
Request Service - Tower service to annotate requests with span
- Request
Id - Request’s id
- Request
Info - Request’s information
- Request
Span - Request’s span information
- Response
Fut - Middleware’s response future
Enums§
- Protocol
- Possible request protocol
Constants§
- REQUEST_
ID - RequestId’s header name
Type Aliases§
- Extract
Client Ip - ALias to function signature to extract client’s ip from request
- Make
Span - Alias to function signature required to create span