Prompt
How do I trace a request across microservices?
Latest observation
Oct 20, 2026
OpenAI APIWeb search: off
To trace a request across microservices, use distributed tracing with a trace ID that is propagated from one service to the next.
Core idea
- Incoming request gets a trace ID
- At the edge (API gateway, ingress, or first service), create or accept a trace ID.
- Pass trace context downstream
- Each service forwards the same trace ID to the next service, usually in HTTP headers or message metadata.
- Create spans per operation
- Each service creates one or more spans for work it does.
- Collect traces in a tracing backend
- A collector stores and visualizes the request path across services.
Common standards/tools
- OpenTelemetry: standard instrumentation and propagation
- W3C Trace Context:
traceparent/tracestateheaders - Backends/UI:
- Jaeger
- Zipkin
- Grafana Tempo
- Datadog / New Relic / Dynatrace
What to propagate
Typically:
traceparent: contains trace ID, parent span ID, flagstracestate: vendor-specific metadata
Example header:
traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-00
Practical setup
- Instrument each service with OpenTelemetry SDK or auto-instrumentation.
- Ensure HTTP clients/servers and message consumers/producers propagate context.
- Export spans to a collector (OTel Collector) and then to your backend.
Benefits
- See the full request flow across services
- Identify latency bottlenecks
- Debug failures and retries
- Correlate logs and metrics with traces
Good practice
- Also include the trace ID in logs so you can jump from logs to traces.
- Use sampling to reduce overhead in high-traffic systems.
If you want, I can show you:
- a language-specific example (Java, Go, Python, Node.js)
- how to do this with OpenTelemetry
- how to trace async/message-based workflows (Kafka, RabbitMQ, SQS)