Misaligned spans exception when used with spring-data-mongodb-reactive and spring-cloud-stream
See original GitHub issueVersions used
Java: 1.8 Spring Boot: 2.4.0-M3 Spring Cloud: 2020.0.0-M4 Spring Cloud Sleuth: 3.0.0-M4
Description of the error
When Spring Cloud Sleuth is used together with Spring Data MongoDB Reactive and Spring Cloud Stream it throws Misaligned spans exceptions.
This is demonstrated by the GitHub project: git@github.com:magnus-larsson/ml-service-sleuth-issue.git
This project contains three tests:
createProductDirect- creates a document in MongoDB using Spring Data MongoDB ReactiveusingStreamWithoutMongoDb- tests Spring Cloud Stream without using MongoDBcreateProductUsingStream- combines usage of Spring Cloud Stream and Spring Data MongoDB Reactive
Test 1 and 2 are ok, while test 3 throws an exception:
Misalignment: scoped span NoopSpan(57d50a0ff0504383/82431158846274f5) != current span LazySpan(57d50a0ff0504383/62a7279d555f7b0e)
java.lang.AssertionError: Misalignment: scoped span NoopSpan(57d50a0ff0504383/82431158846274f5) != current span LazySpan(57d50a0ff0504383/62a7279d555f7b0e)
Instructions to reproduce the error
git clone git@github.com:magnus-larsson/ml-service-sleuth-issue.git
cd ml-service-sleuth-issue
./gradlew test --info
The build will fail and in the log output you can find:
> Task :test FAILED
se.magnus.microservices.core.product.MLTests > createProductUsingStream() FAILED
java.lang.AssertionError: Misalignment: scoped span NoopSpan(1f60cb80f1401bd6/f134e48ecd166acd) != current span LazySpan(1f60cb80f1401bd6/4f33d06bb34e1043)
To make the failing test run ok, one of the following changes can be made to build.gradle:
- Remove
spring-cloud-starter-sleuthfrom the dependencies - Change the Spring Boot version to
2.3.2.RELEASEand Spring Cloud version toHoxton.SR6
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (7 by maintainers)
Top Results From Across the Web
Spring cloud stream / Kafka exceptions - java - Stack Overflow
Basically it means there is no listener on that channel (such as @StreamListener or @ServiceActivator etc). It is a very common Spring ...
Read more >Spring Cloud Sleuth customization
In this section, we describe how to customize various parts of Spring Cloud Sleuth. Please check the appendix for the list of spans,...
Read more >Introduction to Spring Cloud Stream - Baeldung
Learn how to create message-driven and event-driven microservices using Spring Cloud Stream and RabbitMQ.
Read more >Spring Cloud Tutorial - Distributed Log Tracing using Sleuth ...
If suppose during such calls there are some issues like exception has occurred. ... Spring Cloud Sleuth is used to generate and attach...
Read more >Easy Distributed Tracing with Spring Cloud Sleuth
The Spring Boot application will be secured using Okta as an OAuth 2.0 & OIDC provider. You'll use the Okta CLI to configure...
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

Of course it does cause it doesn’t instrument mongo. You can remain with
spring-cloud-starter-sleuthand just setspring.sleuth.mongodb.enabled=falseand you’ll disable it.Hmm, I don’t think it would be much different to support 4.2 or 3.x. It would probably mean that the same amount of extra work for me. But I’ll see what I can do. I’ve never done something like this in the ~10-year history of rest assured 😃