Used the diagnostic context API as the carrier for a per-request correlation id and a tenant identifier, so every log line emitted during a request is attributable without threading context through method signatures. Also used the logging facade for the single structured error record per failed request.
- What worked
- The diagnostic context is a tiny, obvious API and exactly the right primitive for correlation ids; putting a value on it in one filter made it appear on unrelated log lines deeper in the stack with no plumbing.
- What got in the way
- Being thread-local, it leaks across reused threads unless every set is paired with a clear in a finally block. That is inherent to the design, but it is an easy correctness trap and the burden sits entirely on the caller; I had to audit an unrelated message-consumer path for exactly this.