I got this idea to create a servlet filter, that would inspect the thread-local store for the thread currently processing the request and log any thread-local references that exist before the request is dispatched down the chain and also when it comes back. Such a servlet could be packaged as a Confluence Servlet Filter Plugin, so that it is convenient to develop and deploy it.
J. Protze, M. Schulz, D. Ahn, und M. Müller. Proceedings of the 27th International Symposium on High-Performance Parallel and Distributed Computing, Seite 144--155. ACM, (2018)