You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, the kotlinx-coroutines-reactor library copies the Reactor context as a key under the Coroutine Context.
The Spring community has requested many times the transparent propagation of contexts between threadlocals, reactive and coroutine. This lead to the creation of the Micrometer Context Propagation library, a zero dependency small library for this very purpose.
The Spring team received multiple reports of contexts not being propagated as expected between Coroutines and ThreadLocal/Reactor. This feature is required by observability instrumentations that Spring projects provide for metrics and traces in applications.
As explained in this comment, we have considered moving this utility class to several places, unsuccessfully so far. This requires org.jetbrains.kotlinx:kotlinx-coroutines-reactor (a required dependency) and io.micrometer:context-propagation (as an optional dependency) to work.
Kotlin users would still need to opt-in and use this PropagationContextElement, but I think this aligns nicely with the Kotlin developers' expectations.
This enhancement request comes from the Spring Framework team with spring-projects/spring-framework#32165 as background.
Use case
Right now, the
kotlinx-coroutines-reactor
library copies the Reactor context as a key under the Coroutine Context.The Spring community has requested many times the transparent propagation of contexts between threadlocals, reactive and coroutine. This lead to the creation of the Micrometer Context Propagation library, a zero dependency small library for this very purpose.
The Spring team received multiple reports of contexts not being propagated as expected between Coroutines and ThreadLocal/Reactor. This feature is required by observability instrumentations that Spring projects provide for metrics and traces in applications.
See here for a detailed explanation of the missing bits when using Coroutines in a Spring application that expects tracing: spring-projects/spring-framework#32165 (comment)
The Shape of the API
We have refined and tested an implementation that makes all elements work together as expected by Spring+Kotlin users: spring-projects/spring-framework#32165 (comment)
Prior Art
As explained in this comment, we have considered moving this utility class to several places, unsuccessfully so far. This requires
org.jetbrains.kotlinx:kotlinx-coroutines-reactor
(a required dependency) andio.micrometer:context-propagation
(as an optional dependency) to work.Kotlin users would still need to opt-in and use this
PropagationContextElement
, but I think this aligns nicely with the Kotlin developers' expectations.Do you think this
PropagationContextElement
class belongs inorg.jetbrains.kotlinx:kotlinx-coroutines-reactor
? Note thatreactor-core
itself already has deep (but optional) integrations with the context propagation library.Thanks!
cc'ing @sdeleuze on this issue.
The text was updated successfully, but these errors were encountered: