Trace id is not propagated correctly with reactor in AdaptCachedBodyGlobalFilter
Thanks for all the work that you are doing. I already investigated this bug, but I struggle to find the exact root cause and solution.
Describe the bug We use Spring Cloud Gateway (version 4.0.4), Spring Webflux (6.0.13) and project reactor (3.5.11) for a gateway microservice.
We use the DataDog java agent for metrics.
Now, we noticed that sometimes the traces inside Spring Cloud Gateway are not connected correctly: It seems the trace id is not passed on correctly in the context if we have a request with a body.
- There is one trace with 2 spans (
servlet.requestfromtomcat-serverandFilteringWebHandler.handlefromspring-webflux-controller). - The other trace starts with
netty.client.requestfromnetty-clientand then continues as expected.
When I disable AdaptCachedBodyGlobalFilter the traces are correct (spring.cloud.gateway.global-filter.adapt-cached-body.enabled: false)
Can it be that somehow in this filter the original context is lost and thus the tracer does not find the old trace id and uses a new one?
I expect the problem to be either in DataBufferUtils#join or ServerWebExchangeUtils#cacheRequestBody, but I am not sure how to change it, so the context is propagated correctly.