Scrivio Interview library
ScenarioAdvanced6 min read · updated 12 November 2026

Tracing data is missing for calls that go through a mix of WebFlux services, Kafka consumers and MVC services. How would you get consistent context propagation across the fleet?

I would standardise every service on Micrometer Observation and Micrometer Tracing with W3C Trace Context headers, make sure every client and listener (WebClient, RestClient, KafkaTemplate and Kafka listeners) is built from Spring Boot's managed builders or factories so it is instrumented, and enable automatic context propagation in the reactive services. Then I would add tests that assert the trace id survives each kind of hop, and ship all of it in a shared starter so no team configures it separately.

Background to this question

Distributed tracing is only useful when it is complete. A trace that shows the gateway and the first WebFlux service but loses the trail at a Kafka topic, or splits into two unrelated traces at an MVC service, sends on-call engineers back to grepping logs. Gaps like these almost never come from one big mistake; they come from many small ones: a client created with new, a header format mismatch, a listener without observation, a reactive service where the trace id never reaches the MDC. In this answer, we will recap how a trace crosses a hop, find where each kind of service drops it, fix each cause, prove the fix with tests, and package it so it stays fixed.

1A Quick Recap: How a Trace Crosses a Hop

A trace is the record of one request's journey, made of spans, each one a timed unit of work in one service. For a trace to continue from service A to service B, two things must happen. A must write the current trace id and span id into the outgoing request or message, as headers. B must read those headers and start its own span as a child of A's span. This writing and reading is called propagation, and the header format must match on both sides: the W3C Trace Context standard uses a header named traceparent, while older systems use B3 headers from Zipkin.

Inside a service, the current span must also stay attached to the work as it moves between threads, or the outgoing call will not know which trace it belongs to. That is the in-process half of propagation.

Step throughA trace crossing three kinds of hop
WebFlux APIKafkaConsumerMVC service
send order-created, header traceparent
deliver record with headers
listener observation: child span
RestClient call, traceparent
200 OK

5 messages in order. Play them, or step through them one at a time.

Every arrow must carry the header, and every receiver must continue the trace.

2Where the Trace Gets Lost

Most gaps fall into a few categories. The first is uninstrumented clients: WebClient.create(), new RestTemplate() or a KafkaTemplate built by hand do not have the observation registry, so they send no trace headers. The second is format mismatch: one service sends B3, another expects W3C, so the receiver starts a fresh trace. The third is messaging without observation: in Spring Kafka, observation on templates and listeners must be switched on, otherwise records carry no headers and consumers start new traces. The fourth is reactive in-process loss: the WebFlux service receives the header and creates a span, but log lines inside operators lack the trace id and, in some cases, calls made from a different thread do not continue the span, because automatic context propagation is off.

To find which applies, I would pick a few broken traces and follow them hop by hop, comparing the traceparent header in the outgoing request with the incoming one, and checking each service's configuration against the list above.

Common causes of missing trace data
SymptomLikely causeFix
New trace starts after a WebClient callWebClient.create() usedinject WebClient.Builder
New trace starts after an MVC hopB3 sent, W3C expectedmanagement.tracing.propagation.type=w3c
Consumer traces unrelated to producerKafka observation offenable template and listener observation
Reactive logs lack traceIdcontext propagation offspring.reactor.context-propagation=auto
Spans missing in async tasksplain executorcontext-propagating task decorator

3Fixing Each Hop

The fixes are configuration and conventions rather than code. Every service uses Micrometer Tracing with one bridge (to OpenTelemetry or Brave) and W3C propagation, set explicitly with management.tracing.propagation.type=w3c so nobody depends on a default. Clients are always obtained from Boot: inject WebClient.Builder, RestClient.Builder or RestTemplateBuilder, because Boot customises those builders with the observation registry. Kafka observation is enabled on both sides.

Java
# application.yml, the same in every service
management:
tracing:
sampling.probability: 0.1 # sample 10 percent; propagation still happens for all
propagation.type: w3c
spring:
reactor.context-propagation: auto # reactive services; check your Boot version
kafka:
template.observation-enabled: true
listener.observation-enabled: true
// Code: always from the managed builder
@Bean WebClient pricing(WebClient.Builder builder) {
return builder.baseUrl("http://pricing").build(); // instrumented: sends traceparent
}

Notice that sampling and propagation are separate. Even unsampled requests propagate their trace id, so logs can still be correlated; sampling only decides which spans are exported. In the reactive services, automatic context propagation makes the trace id appear in log lines inside operators and keeps the current observation available to calls made later in the pipeline.

4Proving It With Tests

Configuration drifts, so the guarantee must be a test. For each kind of hop, a test sends a request or message with a known traceparent and asserts that the outgoing call carries the same trace id. For HTTP, a mock server such as MockWebServer or WireMock records the outgoing headers; for Kafka, an embedded broker or Testcontainers lets the test read the header from the produced record.

Java
@Test
void outgoingCallKeepsTraceId() {
String incoming = "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01";
webTestClient.get().uri("/orders/42").header("traceparent", incoming)
.exchange().expectStatus().isOk();
RecordedRequest call = pricingServer.takeRequest();
assertThat(call.getHeader("traceparent"))
.contains("4bf92f3577b34da6a3ce929d0e0e4736"); // same trace id, new parent span
}

Beyond tests, I would add a fleet-level check in the tracing backend: a regular query for traces that begin at an internal service rather than at the edge, which usually means a hop dropped the context. Plotting that count per service shows where gaps remain.

5Shipping It in a Shared Starter

Finally, none of this should be repeated in each service. A company starter for MVC and WebFlux sets the propagation type, the context propagation property, Kafka observation and sensible sampling defaults, adds the logging pattern with trace and span ids, and provides the propagation tests as a reusable test fixture. Teams that use the starter get consistent tracing by default; the only rule they must follow is to use the injected builders, which an ArchUnit rule can enforce by failing the build on WebClient.create() or new RestTemplate() in production code.

6Follow-up questions

Why not let each team pick B3 or W3C?

Because propagation only works when sender and receiver agree. W3C Trace Context is the open standard supported by every major tracing system and cloud load balancer. A mixed fleet can temporarily accept both formats while sending W3C, but the end state should be one format everywhere.

What about calls to third-party services?

We still send traceparent, which is harmless, and record a client span for the call, so the trace shows how long the dependency took. We cannot see inside the third party, but we can see the gap, which is often what matters during an incident.

How do batch jobs fit in?

A job run starts its own trace, ideally one observation per run or per chunk, and messages it sends carry that trace. Tracing a ten-hour job as a single span is not useful; per-chunk or per-item observations give a usable picture.

7Conclusion

In this answer, we traced the causes of missing tracing data across WebFlux, Kafka and MVC services to a few categories: clients built without Boot's builders, mismatched header formats, Kafka observation left off, and reactive services without automatic context propagation. We standardised on Micrometer Observation and Tracing with W3C Trace Context, created every client from managed builders, enabled observation on Kafka templates and listeners, turned on context propagation in reactive services, proved each hop with tests, and packaged everything in a shared starter.

What to say in the interviewAbout 90 seconds aloud

Open with

First I would find where traces break by following a few broken traces hop by hop and comparing traceparent headers. In my experience the causes are few. Clients built by hand, like WebClient.create or new RestTemplate, are not instrumented, so they send no headers.

Then, if they want more

Services disagree on format, B3 versus W3C. Kafka templates and listeners have observation switched off, so consumers start fresh traces. And reactive services have automatic context propagation off, so logs inside operators lack trace ids and the span is not available later in the pipeline.

So the standard is: Micrometer Observation and Tracing everywhere, W3C Trace Context set explicitly, every WebClient, RestClient or RestTemplate obtained from Boot's injected builders, spring.kafka template and listener observation enabled, and spring.reactor.context-propagation set to auto in WebFlux services.

Then I prove it with tests per hop type: send a request with a known traceparent and assert, with a mock server or an embedded Kafka, that the outgoing call carries the same trace id. In the tracing backend I would also watch for traces that start at internal services, which points to remaining gaps.

Finally I put all of this in a shared starter with the logging pattern and the test fixtures, and add an ArchUnit rule against hand-built clients, so teams do not configure it themselves.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Tracing data is missing for calls that go through a mix of WebFlux services, Kafka...": https://scrivio-interview-library.netlify.app/spring-boot/webflux/ceb7f6c4c0/