Regression in 3.0.2: tracer context lost when used with spring-data-mongodb
See original GitHub issueDescribe the bug
Hi, I think there’s a regression introduced in 3.0.2. Given an endpoint like:
import org.springframework.cloud.sleuth.Tracer
@GetMapping("chain-with-mongo")
fun chainMongo(): Mono<SpanWrapper> {
val result = SpanWrapper()
return tracer.spanId()
.map { result.add(it) }
.flatMap { repo.insert(Person(it)) }
.flatMap { tracer.spanId() } // <-- spanId is empty here
.map { result.add(it) }
.map { result }
}
fun Tracer.spanId() = currentSpan()?.context()?.spanId().orEmpty().toMono()
After the reactive repository, traceId or spanId are empty.
This happens from 3.0.2. Previous versions (3.0.1 & 3.0.0) are fine.
Other versions:
- Spring Cloud 2020.0.2
- Spring Boot 2.4.4
If I were to guess where this might come from I would point at the recent optimizations in Reactor operator decoration.
Sample
You can find a reproducer here. You can sample the issue by executing ./gradlew test
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
I have upgraded sping-data-mongodb version 3.3.2 and now ...
MongoCollection collection = mongoTemplate.getCollection(“testdb”); i have upgraded sping-data-mongodb version 3.3.2 and now getting errors.
Read more >Trace context lost after mongo call #1204 - GitHub
Hi, using latest Spring versions (2.1.2.RELEASE and Cloud Greenwich.RELEASE) it looks like after calling mongo with reactive operators trace ...
Read more >Spring Data MongoDB - Reference Documentation
The Spring Data MongoDB project applies core Spring concepts to the development of solutions that use the MongoDB document style data store.
Read more >Release Notes Red Hat Fuse 7.0 | Red Hat Customer Portal
Welcome to the Fuse 7.0 GA release! This release continues the evolution of Red Hat Fuse with major component upgrades and expanded range...
Read more >Bug listing with status CONFIRMED as at 2022/12/14 03:46:34
splunk - the search engine for IT data" status:CONFIRMED resolution: severity:enhancement · Bug:128982 - "sys-process/cryopid process freezer (new ebuild)" ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

BTW - if you bump mongodb to version
<mongodb.version>4.2.3</mongodb.version>then things work out of the box without any changes! That’s beacuse Mongo started using project reactor under the hood. I can close this issue then since the recommended approach is to use version 4.2 of the mongodb driverHi! The fact that it used to work had to be accidental. We have done a big analysis with @mp911de and we need to talk to Mongo folks about providing hook points to allow the reactive context propagation. Until now as a workaround you have to IMO use the
WebFluxSleuthOperatorsand the like:I’ll mark this as in progress cause we can’t do much about it ATM.