To support MDC propagation between threadlocal and reactor operation chain, e.g. using WebClient in Spring MVC, I use a custom ThreadLocalAccessor(from micrometer context-propagation) implementation.
It would be more useful if it is provided by Spring Boot and auto-configures.
Implementation sample from this gist by @chemicL
static class MdcAccessor implements ThreadLocalAccessor<Map<String, String>> {
static final String KEY = "mdc";
@Override
public Object key() {
return KEY;
}
@Override
public Map<String, String> getValue() {
return MDC.getCopyOfContextMap();
}
@Override
public void setValue(Map<String, String> value) {
MDC.setContextMap(value);
}
@Override
public void reset() {
MDC.clear();
}
}
To support MDC propagation between threadlocal and reactor operation chain, e.g. using
WebClientin Spring MVC, I use a customThreadLocalAccessor(from micrometer context-propagation) implementation.It would be more useful if it is provided by Spring Boot and auto-configures.
Implementation sample from this gist by @chemicL