OpenTelemetry Distributed Tracing
OTel tracing across two services.
Step 1: SDK in service A
Service A is the entry point of the trace. Wire the SDK in, name the service, and turn on auto-instrumentation for the HTTP server.
- Install. The language-specific OTel SDK plus the auto-instrumentation package for your HTTP framework.
- Tracer. Initialise once at startup with a stable
service.nameresource attribute. - Auto-instrument. The HTTP server middleware emits a span per request without app code changes.
- Exporter. Point at the local Collector via
OTEL_EXPORTER_OTLP_ENDPOINT; do not export to backends directly.
Step 2: SDK in service B
- Same as A but different serviceName.
- Instrument HTTP client (auto-injects W3C Traceparent).
Step 3: Collector + Jaeger
The Collector sits between your apps and the trace backend. Always export through it so you can change backends without redeploying services.
- Compose. Run otel-collector and Jaeger via Docker Compose; the standard demo file in the OTel repo works as-is.
- Pipeline. Receivers ingest OTLP from your apps; processors batch and tag; exporters forward to Jaeger.
- Why Collector. Sampling, tagging, and backend swaps live here, not in app code; one config to update.
- Verify.
http://localhost:16686shows Jaeger; service names you set in Step 1 appear in the dropdown.
Step 4: Trace propagation
Distributed tracing only works when the trace context survives the network boundary between A and B. W3C Traceparent is the standard.
- Outbound. Service A's HTTP client auto-injects
traceparenton every outgoing request. - Inbound. Service B's HTTP server middleware reads
traceparentand starts a child span under it. - Result. Jaeger UI shows the cross-service trace as one timeline with both service spans nested.
- Async caveat. Background jobs and message queues need explicit context propagation; auto-instrumentation does not always cover them.
Antipatterns
- Manual instrumentation everywhere. Use auto-instrumentation libraries.
- No sampling. Cost.
- Skipping context propagation in async. Trace breaks.
What to do this week
Three moves. (1) Run the tutorial end-to-end on your own laptop / sandbox. (2) Apply the pattern to one production workload. (3) Document the variations you needed; share with the team.