Spring Boot 3 Webflux project missing traceId and spanId in logs

See original GitHub issue

When upgrading to Spring Boot 3 (and Micrometer) I noticed the traceId and spanId are not added to the logs when it’s a Webflux project.

Webflux: https://github.com/sanderino666/webflux-micrometer-logs

2022-11-26T17:27:44.991+01:00 INFO [,,] 19376 --- [ctor-http-nio-3] com.example.demo.DemoApplication : home() has been called

MVC: https://github.com/sanderino666/mvc-micrometer-logs

2022-11-26T17:24:12.050+01:00 INFO [,63823dabe8475ad8d31ec1fc81853dcc,d31ec1fc81853dcc] 1848 --- [nio-8080-exec-1] com.example.demomvc.DemoMvcApplication : home() has been called

Issue Analytics

  • State:open
  • Created 10 months ago
  • Reactions:12
  • Comments:30 (11 by maintainers)

github_iconTop GitHub Comments

5reactions
marcingrzejszczakcommented, Nov 29, 2022

It seems the change from Sleuth to Micrometer Tracing is going to need quite a lot of work on our codebases. Can you confirm this is the proper usage?

For now, if you want to have the loggers have correlated MDC context, then yes, it will require some work. Because you could instead of doing doOnNext just call tap() or handle() and then you’ll get the MDC correlated for you.

I’m in touch with @OlegDokuka and the reactor team to work on something more automated that would resemble how Sleuth worked but would be more performant and less buggy. But that will take some time.

3reactions
akoufacommented, Dec 2, 2022

@marcingrzejszczak Ok thank you. Last question: So this means that I can use the function:

suspend fun Logger.d(message: String) {
    Mono.just(Unit).handle { t, u ->
        debug(message)
        u.next(t)
    }.awaitSingleOrNull()
}

in any place in my Spring Boot code and the Reactor context will have the correct values so that trace and span id will be included in the logs?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Boot 3 Webflux application with Micrometer Tracing not ...
I'm replacing Spring Cloud Sleuth to generate log correlation with the new Micrometer Tracing for Spring Boot 3.
Read more >
Get Current Trace ID in Spring Cloud Sleuth - Baeldung
In this article, we'll take a look at Spring Cloud Sleuth and see how we can use it for tracing in Spring Boot....
Read more >
Spring Boot and Tracing Calls - The Blog of Ivan Krizsan
The trace id from the request to the circle resource is preserved but a new span id is generated for the request to...
Read more >
Spring Cloud Sleuth
The initial span that starts a trace is called a root span . The value of the ID of that span is equal...
Read more >
spring-cloud/spring-cloud-sleuth - Gitter
I have created 2 simple projects with one rest controller to have traceid & spanid in logs: Using spring-boot-starter-webflux:2.4.3, ...
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