-
Notifications
You must be signed in to change notification settings - Fork 40.9k
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
Reactive WebClient - TraceId is not propagated to scope function #43421
Comments
I believe this is the expected behavior, @bclozel or @sdeleuze might be able to confirm for sure. The observation is only active whilst the exchange is in progress (see this code). Your |
Actually, I take that back. I see now that the trace ID should remain since it's a child of the |
This log statement does not print the traceId because there is no traceId in the current coroutine execution context; "also" is a coroutine operator: .also {
log.info("Log from also block")
} "map" is a reactor operator and reactor reinstates threadlocals registered with the context propagation library; this log statement prints the traceId because the TraceId has been reinstated by reactor as a threadlocal. This has been enabled with .map {
log.info("Response received")
it
} So to summarize:
I've amended your sample with the suspend fun getString(): String {
return withContext(PropagationContextElement(coroutineContext)) {
client
.get()
.retrieve()
.toEntity(String::class.java)
.map {
log.info("Response received")
it
}
.awaitSingle()
.body!!
.also {
log.info("Log from also block")
}
}
} This logs:
I'm closing this as a duplicate of I think this is a duplicate of spring-projects/spring-framework#32165 If you believe this feature should be supported, please vote for Kotlin/kotlinx.coroutines#4187 |
TraceId is not correctly propagated to scope function after a reactive WebClient call.
Demo project is available here
current output:
expected:
The text was updated successfully, but these errors were encountered: