hyper-trace-id
Axum middleware for adding trace ids to requests.
Basic Usage
Adding the SetTraceIdLayer<T> layer will make TraceId<T> available via the request and
response extensions. For special use-cases (e.g. lazily generating trace ids only in case of http errors) you can implement MakeTraceId on your own types.
use Infallible;
use ;
use ServiceBuilder;
use ;
let trace_id_header = "x-trace-id";
let svc = new
.layer
.service_fn;
Use with axum
For axum users, crate optionally provides an extractor (via the axum feature) to access the trace id in a handler.
use ;
use ;
let app: Router = new
.route
.layer;
Use with tracing
To use with tracing, you can access the requests tracing id via the extensions.
use ;
use ;
use TraceLayer;
use info_span;
let app = new
.route
.layer;
License
This project is licensed under the MIT license.