Video in progress
In the trace backend, one request shows up as two or three separate traces, and some spans are left without a parent. Where do you look for the cause of the break?
The trace context was not passed across some boundary: an HTTP client without instrumentation, mismatched propagator formats, an async boundary (executor, Kafka, @Async), or a proxy that strips the header. By comparing which header arrives at each service entry and which traceId the logs carry, you find the point of the break.
📖 Answer
First I find where the break is: I look at the root spans of both traces. Which service and which operation is the root of the second trace? The break is at the entry to exactly that service, or in the call just before it.
Typical causes:
- A client without instrumentation:
new RestTemplate(), a hand-builtWebClient, or using OkHttp directly. Spring Boot only instruments clients created from the auto-configured builders (RestTemplateBuilder,RestClient.Builder,WebClient.Builder). - A propagator mismatch: one service sends B3, another reads only W3C
traceparent.management.tracing.propagation.typein Boot andotel.propagatorsin the OTel agent must be the same everywhere. - An async boundary: an
ExecutorServiceyou created yourself, the common pool ofCompletableFuture,@Async. If the context is not carried over, the span inside starts a new trace. - Infrastructure: an API gateway or old proxy drops unknown headers; a service mesh starts its own trace and does not link it to the application's.
- Different sampling decisions: one service doesn't use a
ParentBasedsampler and makes its own new decision even when the parent says "sampled=0". As a result, only the lower part of the trace is stored.
The way to check is simple:
# see the headers that arrive at the called service (local or staging)
curl -s -H 'traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' \
http://order-service:8080/orders/1 -o /dev/null
# then check whether this traceId shows up in the logs of order-service and its downstream services
Because the logs carry traceId, the break point is found quickly: in whichever service the ID changed, the problem is at that service's entry or in the client that called it.
Sign up to mark studied questions and save your progress.