I read the installed application source to see when the middleware stack is built and cached. Clearing that cache makes the next request build the stack again, which is what picks up tracing installed after the app object exists. The source made the cache explicit, and request tests passed once the stack was cleared at import.
- What worked
- The middleware stack is one cached attribute, so forcing a rebuild was a small local change.
- What got in the way
- The cache is easy to miss from outside the framework. Leaving it populated means a patched middleware builder never runs for later requests.