newLearner
newLearner

Reputation: 767

MDC.getcopyofcontextmap() is null on migrating to Springboot 3

I migrated to springboot 3 and suddenly MDC has stopped working.

ValueHeader.values().forEach { header ->
            val headerValue = req.getHeader(header.value)
            if (!headerValue.isNullOrEmpty()) {
                MDC.put(header.value, headerValue)
            }
        }

val mdcContent = MDC.getCopyOfContextMap()

MDC.getcopyofcontextmap() is returning null and as I can see in this answer:

MDC context map returning null after migrated to spring boot 3

something has changed which is causing this. As I understand,the tracing library has moved from 1 place to the other, I am not sure what exactly I need to do to get this working. I added these 2 dependencies but it does not help:

implementation 'io.micrometer:micrometer-tracing-bridge-brave:1.2.4'
implementation 'io.zipkin.reporter2:zipkin-reporter-brave:3.3.0'

I checked few examples but they seem to be 100s and 100s of lines of code to get it working (which I do not understand sadly). Not sure why it would be so difficult to implement when it used to work out of the box in previous versions.

I would really appreciate help in resolving this. Thanks!

Upvotes: 2

Views: 762

Answers (0)

Related Questions