We clear the MDC context after every HTTP request in a org.springframework.web.filter.OncePerRequestFilter
.
We now want to use Spring Cloud Sleuth. Spring Cloud Sleuth also sets MDC values.
Is it still OK to clear the whole MDC context after every HTTP request? Or is this interfering with Spring Cloud Sleuth?
Spring Cloud Sleuth uses MDC to ensure that log entries contain the trace and span id. If you clear those entries before a log statement takes place, obviously you won't get entries in the log. However, it will not affect Sleuth. Sleuth reuses ThreadLocals to store the current span's context.