| Crates.io | tower-http-tracing |
| lib.rs | tower-http-tracing |
| version | 0.3.2 |
| created_at | 2025-11-14 07:47:49.896202+00 |
| updated_at | 2026-01-12 02:05:19.708075+00 |
| description | Tracing middleware to span annotated every HTTP request |
| homepage | |
| repository | https://github.com/DoumanAsh/tower-http-tracing |
| max_upload_size | |
| id | 1932435 |
| size | 72,171 |
Tower tracing middleware to annotate every HTTP request with tracing's span
Below is illustration of how to initialize request layer for passing into your service
use std::net::IpAddr;
use tower_http_tracing::{http, HttpRequestLayer};
#[derive(Clone)]
pub struct MyContext;
impl tower_http_tracing::LayerContext for MyContext {
const INSPECT_HEADERS: &'static [&'static http::HeaderName] = &[&http::header::FORWARDED];
//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(&self, span: &tracing::Span, 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, MyContext);
//Use above layer in your service
opentelemetry - Enables integration with opentelemetry to propagate context from requests and into responsesdatadog - Enables integration with specialized datadog tracing layer to propagate context from requests and into responses