Adding automatic instrumentation for middleware is a bit tricky, as a first step we can expose wrappers that users can use to manually wrap their middleware calls. Even if we figure out auto-instrumentation for middleware this will probably be needed by that internally or at least we can still expose it to users as a fallback for cases where auto-instrumentation might fail.
docs
Solution brainstorm: Add a wrapper wrapMiddlewareListWithSentry that users can use to wrap lists of middleware. This should call another exported wrapper wrapMiddlewareWithSentry that can be used to wrap single middlewares. This allows users to have full control over if they just want to wrap everything or do it on a case by case basis. I think one wrapper should handle request and server function middleware simultaneously if feasible to avoid any unnecessary confusion. We should also handle potential double wrapping graciously (for instance to not introduce issues for users that use manual wrapping if we later figure out how to properly instrument middleware automatically).
Docs:
Tests: Add tests that verify that middleware emits spans.
Adding automatic instrumentation for middleware is a bit tricky, as a first step we can expose wrappers that users can use to manually wrap their middleware calls. Even if we figure out auto-instrumentation for middleware this will probably be needed by that internally or at least we can still expose it to users as a fallback for cases where auto-instrumentation might fail.
docs
Solution brainstorm: Add a wrapper
wrapMiddlewareListWithSentrythat users can use to wrap lists of middleware. This should call another exported wrapperwrapMiddlewareWithSentrythat can be used to wrap single middlewares. This allows users to have full control over if they just want to wrap everything or do it on a case by case basis. I think one wrapper should handle request and server function middleware simultaneously if feasible to avoid any unnecessary confusion. We should also handle potential double wrapping graciously (for instance to not introduce issues for users that use manual wrapping if we later figure out how to properly instrument middleware automatically).Docs:
Tests: Add tests that verify that middleware emits spans.