Out of the box MDC support in WebClient #24416
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: declined
A suggestion or change that we don't feel we should currently apply
When using
WebClient
in servlet environment, MDC is one of the pain point that requires boilerplate code.Since
RestTemplate
is in maintenance mode, more and more apps would choose to useWebClient
.It would be very helpful that spring provides out of the box support for MDC for the use of
WebClient
. Then, it would be a smooth ride migratingRestTemplate
toWebClient
.Since spring already detects underlying logging framework, it could be implemented agnostic to the actual logging framework.
What needs to be implemented:
Pass MDC values from main thread to reactor thread
In servlet environment, it is required to propagate MDC context values from servlet thread to reactor thread.
To implement,
ExchangeFilterFunction
or some sort of hook which should apply as the first action of response operators.Pass around MDC values to subscriber context within reactor schedulers/operators
My suggestion to reactor-addons. Add-on to support MDC reactor/reactor-addons#219
If such boilerplate code is provided from spring, then, spring-boot may auto-configure the MDC support.
Relates to reactor/reactor-core#1985
The text was updated successfully, but these errors were encountered: