Set custom traceId in Spring WebFlux app with own value set via HTTP Header

85 views Asked by At

Our team needs to push custom traceId into OTLP tracing, which is being generated on frontend side & published in our app via custom HTTP Header. At the moment this is not possible as micrometer generates ImmutableTracingContext.

Using custom traceId makes possible to control behaviour of tracing from external source & it provides option to trace request from external frontend app across the microservice chain.

Backend app is using Spring Boot 3.1 & Micrometer tracing.

We tried to overwrite autogenerated traceId in ServerWebExchange GlobalFilter via:

MDC.put(TRACE_ID, providedXRequestId);

ThreadContext.put(TRACE_ID, providedXRequestId);

However it's not working.

0

There are 0 answers