htmoia
htmoia

Reputation: 491

TraceId and SpanId not available after migrating to Spring Boot 3

After migrating spring boot from version 2.x to 3 we miss traceId and spanId in our logs.

We removed all sleuth dependencies and added

implementation 'io.micrometer:micrometer-core'
implementation 'io.micrometer:micrometer-tracing'
implementation 'io.micrometer:micrometer-tracing-bridge-brave'
implementation platform('io.micrometer:micrometer-tracing-bom:latest.release')

as well as

logging.pattern.level: "%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]"

but no traceIds and spanIds are being logged.

Is there something we missed?

Upvotes: 14

Views: 14795

Answers (2)

Himanshu1
Himanshu1

Reputation: 1

If it is a Spring Webflux project you won't be able to see the traceId and spanId as the micrometer does not support that in sprint boot 3. If its Spring MVC then you should be able to see the traceId and SpanId.

https://github.com/spring-projects/spring-boot/issues/33372

https://github.com/spring-projects/spring-framework/issues/29466

Upvotes: 0

Jonatan Ivanov
Jonatan Ivanov

Reputation: 6931

You need actuator and a bridge, the rest you included is not needed:

implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-tracing-bridge-brave'

If you also want to report your spans, you should add the zipkin reporter too:

implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-tracing-bridge-brave'
implementation 'io.zipkin.reporter2:zipkin-reporter-brave'

Here's an example on start.spring.io and there are a lot of samples in the micrometer-samples repo.

Upvotes: 10

Related Questions