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
Issue related to Spring Boot WebFlux and micrometer while the system uses different executors #643
Comments
I have found that it should be propagated by hand like in this tutorial https://www.youtube.com/watch?v=6OKS36PSpho public static void main(String[] args) {
Hooks.enableAutomaticContextPropagation();
SpringApplication.run(AuthorityServiceApplication.class, args);
} Interceptor for trace ID creation @Slf4j
@RequiredArgsConstructor
@GrpcGlobalServerInterceptor
public class TracerInterceptor implements ServerInterceptor, ClientInterceptor {
private final String TRACE_ID = "traceId";
private final Metadata.Key<String> TRACE_ID_KEY = Metadata.Key.of(TRACE_ID, Metadata.ASCII_STRING_MARSHALLER);
private final Tracer tracer;
@Override
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next) {
Optional.ofNullable(headers.get(TRACE_ID_KEY)).ifPresentOrElse(traceId -> MDC.put(TRACE_ID, traceId), () -> tracer.withSpan(tracer.nextSpan()));
ContextRegistry.getInstance().registerThreadLocalAccessor(TRACE_ID, () -> MDC.get(TRACE_ID), traceId -> MDC.put(TRACE_ID, traceId), () -> MDC.remove(TRACE_ID));
return next.startCall(call, headers);
}
} And add data into the context of your chain: ...
.contextCapture(); Is it expected that gRPC doesn't create trace ID automatically? Thank you. |
AFAIK, Spring has no official gRPC support. Whichever community supported project that the Some remarks regarding the code above:
|
We tried to use micrometer tracing with WebFlux gRPC and, it looks like, the context doesn't populate between executors during the one request.
Result
We can see that before DB-operation the log has a trace ID and executor ault-executor-0 but after selection, the race ID is empty and, as expected, we have another executor actor-tcp-nio-2.
There are dependencies which are used:
Spring Boot 3.1.5
The main method also has Hooks.enableAutomaticContextPropagation
The text was updated successfully, but these errors were encountered: