spring-cloud / spring-cloud-sleuth

Distributed tracing for spring cloud
https://spring.io/projects/spring-cloud-sleuth
Apache License 2.0
1.78k stars 782 forks source link

Trace context lost after mongo call #1204

Closed beltram closed 5 years ago

beltram commented 5 years ago

Bug report Hi, using latest Spring versions (2.1.2.RELEASE and Cloud Greenwich.RELEASE) it looks like after calling mongo with reactive operators trace context is resetted (ie one cannot get back traceId). If mongo is not called it works as expected. It looks like this:

tracer.spanId() // has a value
    .flatMap { repo.insert(Person(it)) }
    .flatMap { tracer.spanId() } // is null

Reproducer is here Thank you 😄

jntakpe commented 5 years ago

Is it related to https://github.com/reactor/reactor-core/pull/1481 ?

jntakpe commented 5 years ago

@bsideup Thoughts ?

bsideup commented 5 years ago

@jntakpe no, not related (the PR you linked is not integrated yet).

Looks more like a duplicate of #1203 and #1199

jntakpe commented 5 years ago

We have experienced the #1199. We solved it by retrieving trace information from request.

beltram commented 5 years ago

For information issue appeared on spring-cloud-sleuth-core:2.1.0.M2

marcingrzejszczak commented 5 years ago

@beltram should I just clone https://github.com/beltram/sleuth-data-reproducer and run ./gradlew clean build to replicate the problem?

beltram commented 5 years ago

@marcingrzejszczak sorry missed the readme on this one. Run ./gradlew clean test instead all logic is in test classes

jntakpe commented 5 years ago

@marcingrzejszczak any issues regarding this issue ?

hsk3mis commented 5 years ago

@beltram Hi. Did you manage to solve your issue? If yes, did you manage to log traceId's from the Mongo driver logs? Eg. org.mongodb.driver.protocol.command : Sending command '{ "find" : "deliveryMethods", "batchSize" : 2147483647 }'