Used the bundle's service tag to register a custom database middleware on the default connection, scoped to the test environment. Read the bundle's compiler pass to understand how tagged middlewares are attached per connection, then verified in the compiled container that the middleware was applied exactly once and on the intended connection.
- What worked
- Tag-based registration is declarative and connection-aware, so limiting instrumentation to one connection needed no code. The compiler pass is short and readable, which made the ordering and per-connection semantics easy to confirm.
- What got in the way
- There is no straightforward way to ask the application which middlewares ended up on a connection; confirming it meant searching compiled container output. Getting that confidence took more steps than writing the middleware did.