-
Notifications
You must be signed in to change notification settings - Fork 700
Description
I'm using Spring Boot 3.2.2 with reactive stack. When I added micrometer tracing I noticed that calls to ReactiveCrudRepository are dropping/resetting tracing context. Call to a repo and all subsequent calls in the same flow are exported to Jaeger with a new TraceID.
I tried other flows. Spring Cloud Stream consumer is passing tracing context downstream, producer too. Custom class annotated with @Observed behave as expected too.
The problem appears only if Spring Cloud Stream is the entry point to the app, if it's using REST API (webflux) everything works as expected. I tried to save data to MongoDB and MariaDB (using R2DBC)ReactiveCrudRepository both behave the same way.
I prepared an example app that contains a couple of modules.
https://github.com/mzalewski82/spring-data-reactive-repo-tracing
web exposes REST API, sends data to Kafka using Spring Cloud Stream, saves data to MongoDB using ReactiveCrudRepository.
kafka-stream-reactive-proxy Pure Spring Cloud Stream, read from one Kafka topic and forwards it to another used by other apps.
kafka-stream-reactive-client and kafka-stream-r2dbc-client both read from Kafka using Spring Cloud Stream and save to MongoDB and R2DBC.
kafka-stream-client used to compare with non-reactive flow. Here everything works perfectly.
All reactive modules contain a class HelloSpan annotated with @Observed, to add more visibility to the issue I'm reporting.
- In
webtrace started in the endpoint is propagated correctly. Full flow is visible in Jaeger. kafka-stream-reactive-proxyno problems with the tracing context.kafka-stream-reactive-clientandkafka-stream-r2dbc-clienttracing context is ok untilReactiveCrudRepositorycall.
I added docker-compose to make it easy to run my example. kafka-stream-r2dbc-client contains a simple sql script too to create necessary schema and table.