For async requests, thread-bound resources should be cleaned in method afterConcurrentHandlingStarted of TracingHandlerInterceptor interceptor as is suggested in the document AsyncHandlerInterceptor.
|
public void afterConcurrentHandlingStarted ( |
In this case, I suppose active scope should be closed since this specific thread will be released back to the dispatch pool and possibly used later for subsequent requests. If the scope is not closed properly, the following requests cannot be traced.
Simply adding the following code at the end of afterConcurrentHandlingStarted makes it work,
Deque<Scope> scopeStack = getScopeStack(httpServletRequest);
if (scopeStack.size() > 0) {
Scope scope = scopeStack.pop();
scope.close();
}