-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
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.
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:
- Update public docs
- Update in-product onboarding
Tests: Add tests that verify that middleware emits spans.
- Global Request Middleware
- Global Server Function Middleware
- Request Middleware
- Server Function Middleware