Build a tracing span for an inbound request, recording the `request_id` header (set by [`UuidRequestId`] or supplied by the client).
(req: &Request<B>)
| 57 | /// Build a tracing span for an inbound request, recording the `request_id` |
| 58 | /// header (set by [`UuidRequestId`] or supplied by the client). |
| 59 | fn make_request_span<B>(req: &Request<B>) -> Span { |
| 60 | let path = req.uri().path(); |
| 61 | let request_id = req |
| 62 | .headers() |
| 63 | .get("x-request-id") |
| 64 | .and_then(|v| v.to_str().ok()) |
| 65 | .unwrap_or("-"); |
| 66 | |
| 67 | if matches!(path, "/health" | "/healthz" | "/readyz") { |
| 68 | tracing::debug_span!( |
| 69 | "request", |
| 70 | method = %req.method(), |
| 71 | path, |
| 72 | request_id, |
| 73 | ) |
| 74 | } else { |
| 75 | tracing::info_span!( |
| 76 | "request", |
| 77 | method = %req.method(), |
| 78 | path, |
| 79 | request_id, |
| 80 | ) |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | /// Log response status and latency within the request span. |
| 85 | fn log_response<B>(res: &Response<B>, latency: Duration, _span: &Span) { |