Skip to content

typescript.missing_correlation_id

Observability Medium

Detects HTTP handlers without correlation ID propagation for distributed 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)
app.get('/users/:id', async (req, res) => {
const user = await userService.getUser(req.params.id);
res.json(user);
});
// ✅ After (with correlation ID)
import { v4 as uuid } from 'uuid';
app.use((req, res, next) => {
req.correlationId = req.headers['x-correlation-id'] as string || uuid();
res.setHeader('x-correlation-id', req.correlationId);
next();
});
app.get('/users/:id', async (req, res) => {
const user = await userService.getUser(req.params.id, {
correlationId: req.correlationId,
});
res.json(user);
});
  • Handlers without correlation ID extraction
  • Missing correlation ID header forwarding
  • Logs without correlation context