rust.missing_correlation_id
Observability
Medium
Detects HTTP handlers or services without correlation ID propagation for request tracing.
Why It Matters
Section titled “Why It Matters”Missing correlation IDs:
- Break tracing — Can’t follow requests across services
- Hinder debugging — No way to correlate logs
- Increase MTTR — Slower incident resolution
Example
Section titled “Example”// ❌ Before (no correlation ID)async fn handle_request(req: Request) -> Response { let result = service.process(req.body).await?; Ok(Response::new(result))}// ✅ After (with correlation ID)use uuid::Uuid;
async fn handle_request(req: Request) -> Response { let correlation_id = req .headers() .get("x-correlation-id") .map(|v| v.to_str().unwrap_or_default().to_string()) .unwrap_or_else(|| Uuid::new_v4().to_string());
let span = tracing::info_span!("request", correlation_id = %correlation_id);
async move { let result = service.process(req.body).await?; Ok(Response::builder() .header("x-correlation-id", correlation_id) .body(result)?) }.instrument(span).await}What Unfault Detects
Section titled “What Unfault Detects”- Handlers without correlation ID extraction
- Missing correlation ID header forwarding
- No tracing span with correlation ID