Skip to content

Conversation

logaretm
Copy link
Collaborator

@logaretm logaretm commented Sep 26, 2025

This pull request introduces instrumentation for Nuxt middleware, ensuring that all middleware handlers are automatically wrapped with tracing and error reporting functionality. The integration is achieved through build-time transformation.

recap:

  • Adds a new build-time Rollup plugin (middlewareInstrumentationPlugin) that automatically wraps all detected middleware handlers with Sentry instrumentation during the Nitro build process.
  • Implements the wrapMiddlewareHandler utility, which wraps middleware handlers to start a Sentry span, capture request data, record exceptions, and flush events in serverless environments.
  • Updates the Nuxt module setup to inject Sentry middleware imports and instrumentation hooks during initialization, ensuring the new tracing logic is included in server builds.

TODO:

  • Test traces and span visibility.
  • Add unit/integration tests.
  • Add E2E tests.
  • Check to see if there are other ways to add middleware that would bypass the transformer.

@logaretm logaretm changed the title feat: implement nuxt server middleware instrumentation feat(nuxt): implement server middleware instrumentation Sep 26, 2025
Copy link
Contributor

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 8,588 - 8,926 -4%
GET With Sentry 1,338 16% 1,388 -4%
GET With Sentry (error only) 6,109 71% 6,167 -1%
POST Baseline 1,197 - 1,192 +0%
POST With Sentry 528 44% 521 +1%
POST With Sentry (error only) 1,063 89% 1,034 +3%
MYSQL Baseline 3,338 - 3,366 -1%
MYSQL With Sentry 513 15% 468 +10%
MYSQL With Sentry (error only) 2,754 83% 2,732 +1%

View base workflow run

@logaretm logaretm force-pushed the awad/instrument-nuxt-nitro-middlewares branch from e7b0353 to a8ce604 Compare September 26, 2025 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant