This has been brought up here: https://github.com/spring-projects/spring-framework/issues/27522#issuecomment-1734248442 and here https://github.com/micrometer-metrics/tracing/issues/174#issuecomment-1847115940.
Problem: if multiple CoWebFilters are called in a chain, the coroutine context from the last one will end up saved in CoWebFilter.COROUTINE_CONTEXT_ATTRIBUTE
. Additionally, each subsequent filter won't be able to take advantage of context modifications from the previous filter in the chain.
E.g. if I have the following two filters in my project: * CorrIdFilter.kt * ObservationFilter only one of them will be able to provide coroutine context for the actual controller method.
Proposed solution: check if attribute is already present in the context and re-use it within the filter. Here is a fast-and-dirty implementation: ImprovedCoWebFilter