Ihor M.
Ihor M.

Reputation: 3148

Spring Cloud Sleuth stopped pushing X-B3-TraceId into MDC after spring-boot/spring cloud upgrade

I have upgraded my Spring boot dependencies from 2.1 to 2.4.5 and spring cloud to 2020.0.2. After this upgrade, my MDC context is not populated.

Any ideas of what should be done here?

Upvotes: 3

Views: 8832

Answers (3)

63RMAN
63RMAN

Reputation: 628

Try checking if you are not calling MDC.clear(); before.

Upvotes: 0

bilak
bilak

Reputation: 4966

in spring cloud 2020.0.2 you have sleuth 3.x and there is a migration guide telling about some changes to MDC

Upvotes: 5

Jonatan Ivanov
Jonatan Ivanov

Reputation: 6941

I think the answer depends on your use-case but as far as I remember, there was a change and the MDC context is cleaned-up after the span is finished.

This means that if you are in the scope of the Span (e.g.: controller method), you can see the Sleuth-related parts of the MDC but if you are outside of the scope of the span (e.g.: Tomcat access logs), you don't.

To test this, try to log out the MDC context map inside of the controller method, the MDC context should contain the tracing-related fields.

Upvotes: 0

Related Questions