Apply contextCapture automatically in await
function
#59
Labels
❓need-triage
This issue needs triage, hasn't been looked at by a team member yet
await
function
#59
Motivation
This is a similar issue.
reactor/reactor-core#3406
For users using kotlin coroutine, ThreadContextElement is used to propagate MDC, etc.
The block operator is supported by Hooks.automaticContextPropagation, but not the await function. Therefore, we are forced to write it this way.
It would be great if the await function is also supported, like the block operator.
Reproduction code
I have created a sample project.
https://github.com/be-hase/context-propagation-report-202309/tree/main/coroutines-issue
The code is in one file.
https://github.com/be-hase/context-propagation-report-202309/blob/main/coroutines-issue/src/main/kotlin/example/CoroutinesIssueApplication.kt
You can start it with the following command.
Then, request with curl.
The log shows that the context is not propagating. (see last log)
Desired solution
The await function is implemented on the coroutine side, maybe I should make a request on the coroutine side.
https://github.com/Kotlin/kotlinx.coroutines/blob/1ccc96890d38be52d1bdcd31af5befb54804aa05/reactive/kotlinx-coroutines-reactor/src/Mono.kt#L46
But, I found that the following workaround can be done using the
ContextInjector
mechanism provided by the coroutines side.If this method is acceptable, I will send you a PR.
Considered alternatives
Additional context
I originally submitted my request here.
reactor/reactor-core#3563
The text was updated successfully, but these errors were encountered: