question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Misaligned spans exception when used with spring-data-mongodb-reactive and spring-cloud-stream

See original GitHub issue

Versions 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:

  1. createProductDirect - creates a document in MongoDB using Spring Data MongoDB Reactive
  2. usingStreamWithoutMongoDb - tests Spring Cloud Stream without using MongoDB
  3. createProductUsingStream - 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:

  1. Remove spring-cloud-starter-sleuth from the dependencies
  2. Change the Spring Boot version to 2.3.2.RELEASE and Spring Cloud version to Hoxton.SR6

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
marcingrzejszczakcommented, Dec 9, 2020

Of course it does cause it doesn’t instrument mongo. You can remain with spring-cloud-starter-sleuth and just set spring.sleuth.mongodb.enabled=false and you’ll disable it.

0reactions
johanhalebycommented, Dec 10, 2020

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 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found