-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Baggage not traced in server request/response logs #361
Comments
I might faceing a similar issue. i'm using spring boot 3.1.4 and micrometer-tracing 1.1.5. The "BaggageField" context propagation for org.springframework.web.reactive.function.client.WebClient header values seems to work but not for mdc values. Hooks.enableAutomaticContextPropagation() is activated. It might be related to #363 or #359. Sometimes baggage fields are there but not up to date. I initialized the WebClient like this (using zalando logbook to log request/responses)
and BaggaeField like this:
|
As for the WebClient side, it works for me, you can take a look at my WebClient configuration in my sample. The trick is to wrap Logbook's server handler with some custom Netty handler that restores a the context during the pipeline. |
@grassehh are you sure the whole configuration is necessary? i miss the simplicity from sleuth.... |
Pretty sure, somehow the Logbook server handler does not seem to be compatible out of the box with Netty. Check this issue reactor/reactor-netty#2850, this is where the suggestions have been made. On Spring Boot 2 with Spring Sleuth, you had to configure it using @Bean
fun reactorNettyHttpTracing(httpTracing: HttpTracing) = ReactorNettyHttpTracing.create(httpTracing)
@Bean
fun httpClientCustomizer(reactorNettyHttpTracing: ReactorNettyHttpTracing) = ReactorNettyHttpClientMapper {
reactorNettyHttpTracing.decorateHttpClient(it)
}
@Bean
fun webClientCustomizer(clientHttpConnector: ClientHttpConnector) = WebClientCustomizer {
it.clientConnector(clientHttpConnector)
} Maybe Micrometer could add some specific instrumentation for Spring or Netty I don't know, but for now, they are totally separated projects. |
@violetagg what is the current micrometer observation way of instrumenting this? ☝️ |
From what I understood the trace id is there, only the custom baggage is not. @grassehh Is that correct? |
it worked when i add a TracingChannelDuplexHandler to the WebClient. In my case custom baggage fields seems to work as well. @grassehh thanks for your help and sorry for capture your issue |
yes for the client there is no issue, the issue is for the server |
@violetagg @marcingrzejszczak @stefan-g |
@marcingrzejszczak make sure you checkout the |
@violetagg @marcingrzejszczak since spring-boot 3.2.0 and/or micrometer-tracing-bom 3.7.0, the traceId in the server logs is now different than in the other logs.
As of the missing custom baggages, the issue is still present. I also created an issue on logbook as I'm not sure about who's responsible of fixing this (Logbook, Micrometer or Spring). |
@grassehh Can you please test with Spring Framework |
Confirm this works with |
Thanks for checking @grassehh ! |
Some background first
I had created an issue to Reactor Netty in order to find out how to replace the deprecated ReactorNettyHttpTracing class when migrating from Spring Boot 2 w/ Spring Cloud Sleuth to Spring Boot 3 w/ Micrometer.
After some suggestions from Violetta, we came to a solution that uses Netty's channel handlers mecanism.
Describe the bug
The custom baggages added through the
Tracer.createBaggageInScope()
method are not traced in the server request/response logs. They are however correctly traced in the controller and webClient calls logs.Steps to Reproduce
issues/micrometer-tracing
branchYou will see that in the server request/response log, there is no custom baggage logged in the MDC:
Expected result
The custom baggages in scope (myBaggageFilter and myBaggageControlelr) should be traced in the server request/responses logs.
This used to work with Spring Cloud Sleuth, using ReactorNettyHttpTracing.
This issue is quite blocking for our project because we need to migrate to Spring Boot 3 and we need to have custom baggages to correlate and filter our logs on Datadog.
Thanks for the help
The text was updated successfully, but these errors were encountered: