1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! Request ID generation and propagation.
//!
//! Each incoming request is assigned a UUID v7 (or inherits one from the
//! `X-Request-ID` header). The ID is stored in request extensions, set as
//! a task-local for access from any async context, and echoed back in
//! the response headers.
/// HTTP header name for request ID propagation.
pub const X_REQUEST_ID: &str = "X-Request-ID";
/// Request ID stored in axum request extensions by the logging middleware.
/// Other middleware (auth, transaction) reads this for correlation.
String);
// Task-local request ID accessible from any async context within a request.
// Used by error handlers to attach correlation IDs without threading
// the ID through every function parameter.
task_local!
/// Retrieve the current request's ID from task-local storage, if available.
/// Returns the raw string so non-UUID request IDs (e.g., from external
/// headers) are still available for correlation.