Use OpenTelemetry SDK with auto-instrumentations initialized before app bootstrap. Inject trace context into Kafka message headers when publishing. Extract the parent trace context from headers when consuming so all spans across services appear in the same trace in Jaeger or Zipkin.
Initialize the OpenTelemetry SDK before NestFactory.create() — import tracing.ts as the first line of main.ts.
Inject propagation headers (traceparent, tracestate) into every outgoing Kafka/RabbitMQ message.
Extract propagation headers from every incoming message and restore the parent context.
auto-instrumentations-node instruments HTTP, database, and Redis calls automatically — no manual spans needed for common operations.
Use a sampling strategy in production — tracing 100% of requests at high traffic is expensive.