Prompt
trace requests across microservices
Latest observation
Oct 6, 2026
OpenAI APIWeb search: off
To trace requests across microservices, you typically add distributed tracing with a shared trace ID that is passed from service to service.
Core idea
- Each incoming request gets a trace ID
- Each service creates a span for its part of the work
- The trace ID and span context are propagated through HTTP/gRPC/message queues
- A tracing backend reconstructs the full request path
Common tools
- OpenTelemetry for instrumentation and context propagation
- Jaeger or Zipkin for trace visualization
- Prometheus + Grafana for metrics alongside tracing
How it works
- Edge service receives request
- Generates or extracts trace context from headers
- Service A handles request
- Creates a span
- Calls Service B and forwards trace headers
- Service B continues the same trace
- Creates child span
- Calls downstream services similarly
- Collector/exporter sends spans
- Spans are exported to tracing backend
- UI shows end-to-end flow
- You can see latency, errors, and the full path
Important headers / propagation
For HTTP, common formats:
traceparent/tracestate(W3C standard)b3headers (Zipkin/OpenTracing legacy style)
Example flow
Client -> API Gateway -> User Service -> Payment Service -> Inventory Service
Each hop adds a span, all tied together by the same trace ID.
Best practices
- Use automatic instrumentation when possible
- Make sure all services propagate context
- Include request ID / correlation ID for logs too
- Sample traces intelligently to control cost
- Add attributes like:
- service name
- endpoint
- status code
- user/tenant ID if safe
- DB/query or external call info
Minimal implementation pattern
- Extract trace context from incoming request
- Start a span
- Inject trace context into outgoing requests
If you want, I can show:
- a language-specific example (Java, Go, Python, Node.js), or
- how to set this up with OpenTelemetry + Jaeger.