reactor-core
reactor-core copied to clipboard
Context Propagation next steps
This issue is meant to coordinate tasks required for context-propagation library integration and propagation of ThreadLocal values in Reactor to be in a desired state.
More details to come.
- [x] context-propagation: Improve
ThreadLocalAccessorcontract to allow entering an empty scope and reverting previously stacked values- https://github.com/micrometer-metrics/context-propagation/pull/102
- https://github.com/micrometer-metrics/context-propagation/pull/103
- [x] context-propagation: Allow Reactor's use case - restoring
ThreadLocalvalues by removing existing values whenContextobject doesn't have a mapping for a key -> replacing the custom implementation within reactor-core- https://github.com/micrometer-metrics/context-propagation/pull/105
- https://github.com/reactor/reactor-core/pull/3489
- [x] reactor-core: Allow configuring automatic context capture in
block()- https://github.com/reactor/reactor-core/pull/3420
- [x] reactor-core + reactor-netty: Allow distinguishing
FluxandMonothat is guaranteed to haveThreadLocalvalues present in case of automatic context propagation from custom implementations that can switch threads (reactor-netty case when execution continues after event on the event loop); allow custom implementations to use a propagatingSubscriber.- #3478
- [x] reactor-core: Remove the queue wrapper hook from automatic context propagation - it can be a source of
ThreadLocalleaks, while it does not provide value in the current design. [depends on the above to be sure source signals have ThreadLocal values restored]- https://github.com/reactor/reactor-core/pull/3498
- [ ] reactor-core: In 3.7 remove automatic
ThreadLocalrestoration in handle/tap operators and provide means to wrap a user-provided function to haveThreadLocals present. Currently there is no opt-out from the TL restoration in these operators when the context-propagation library is on the classpath; this might be undesired when users want to explicitly have TLs present in only particular places that they control.- Consider using properties to drive this feature: in 3.6 have the property of handle/tap restoration set to true, while in 3.7 have it as false
- [x] spring-boot: config knob for automatic context propagation
- https://github.com/spring-projects/spring-boot/issues/34201
- [x] Documentation update
- https://github.com/reactor/reactor-core/pull/3617
- [ ] reactor-core: Research means to optimise the amount of ThreadLocal accesses (e.g. distinguish custom Mono that is not async and not restore ThreadLocals by a wrapping Subscriber)