Skip to content

rust.missing_correlation_id

Observability Medium

Detects HTTP handlers or services without correlation ID propagation for request tracing.

Missing correlation IDs:

  • Break tracing — Can’t follow requests across services
  • Hinder debugging — No way to correlate logs
  • Increase MTTR — Slower incident resolution
// ❌ 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
}
  • Handlers without correlation ID extraction
  • Missing correlation ID header forwarding
  • No tracing span with correlation ID