Skip to content

feat!: Use middleware span op for web-server middleware - #22852

Open
msonnb wants to merge 4 commits into
developfrom
ms/js-3105-middleware-span-op
Open

feat!: Use middleware span op for web-server middleware#22852
msonnb wants to merge 4 commits into
developfrom
ms/js-3105-middleware-span-op

Conversation

@msonnb

@msonnb msonnb commented Jul 30, 2026

Copy link
Copy Markdown
Member

Migrates every web-server middleware span to the single generic middleware op from conventions, replacing the library-specific ops (middleware.express, middleware.koa, middleware.hono, middleware.elysia, middleware.nestjs, middleware.nuxt, middleware.nitro, middleware.tanstackstart, and Fastify’s hook.fastify).

Part of #22446

Middleware spans across the web-server integrations now use the single
generic `middleware` op instead of library-specific leaves
(`middleware.express`, `middleware.koa`, `middleware.hono`,
`middleware.elysia`, `middleware.nestjs`, `middleware.nuxt`,
`middleware.nitro`, `middleware.tanstackstart`, and Fastify's
`hook.fastify`).

The framework is already identified by the span's `sentry.origin`
(`auto.http.express`, `auto.middleware.hono`,
`auto.middleware.nestjs.guard`, ...), so the library-specific op leaf was
redundant. Origins, mechanism types, and the sibling `router.*` /
`request_handler.*` / `handler.*` / `function.*` ops are left untouched —
those are separate rows in the op cleanup and keep their current values.

Fastify's instance hooks map to `middleware`; its handler hook keeps
`request_handler.fastify`. Elysia's lifecycle map collapses to
`middleware` except `Handle`, which keeps `request_handler.elysia`.

nitro and nuxt gain a `@sentry/conventions` dependency (matching the
other server packages) so they can import the shared op constant.

Part of #22446

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Jul 30, 2026

Copy link
Copy Markdown

JS-3105

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.82 kB - -
@sentry/browser - with treeshaking flags 28.02 kB - -
@sentry/browser (incl. Tracing) 47.08 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 47.09 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.82 kB - -
@sentry/browser (incl. Tracing, Replay) 86.39 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.83 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 91.11 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 103.76 kB - -
@sentry/browser (incl. Feedback) 47.13 kB - -
@sentry/browser (incl. sendFeedback) 34.66 kB - -
@sentry/browser (incl. FeedbackAsync) 39.76 kB - -
@sentry/browser (incl. Metrics) 30.89 kB - -
@sentry/browser (incl. Logs) 31.12 kB - -
@sentry/browser (incl. Metrics & Logs) 31.8 kB - -
@sentry/react 31.6 kB - -
@sentry/react (incl. Tracing) 49.33 kB - -
@sentry/vue 34.74 kB - -
@sentry/vue (incl. Tracing) 49.05 kB - -
@sentry/svelte 29.85 kB - -
CDN Bundle 31.87 kB - -
CDN Bundle (incl. Tracing) 47.45 kB - -
CDN Bundle (incl. Logs, Metrics) 33.42 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 48.82 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 72.78 kB - -
CDN Bundle (incl. Tracing, Replay) 85.08 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.38 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 90.85 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.16 kB - -
CDN Bundle - uncompressed 95.04 kB - -
CDN Bundle (incl. Tracing) - uncompressed 142.27 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 99.75 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 146.25 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 224.51 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 261.52 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 265.49 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 275.23 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 279.18 kB - -
@sentry/nextjs (client) 51.92 kB - -
@sentry/sveltekit (client) 47.51 kB - -
@sentry/core/server 79.6 kB +0.02% +14 B 🔺
@sentry/core/browser 51.58 kB - -
@sentry/node 121.32 kB +0.04% +44 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 166 B - -
@sentry/node - without tracing 84.77 kB -0.01% -1 B 🔽
@sentry/aws-serverless 93.02 kB - -
@sentry/cloudflare (withSentry) - minified 197.59 kB - -
@sentry/cloudflare (withSentry) 485.77 kB - -

View base workflow run

msonnb and others added 2 commits July 30, 2026 13:55
Span creation sites set the op through the `sentry.op` attribute rather
than the `op:` shorthand. hono and tanstackstart set both before; koa set
only `op:` and now sets only the attribute (matching express, nestjs,
nuxt, nitro, and elysia, which were already attribute-only). Unit tests
that assert on the start-span call arguments are updated accordingly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The shared fastify hook wrapper set its op through the `op:` shorthand;
it now sets `sentry.op` in attributes instead, matching koa/hono/
tanstackstart. The op is only added when defined so route-hooks (which
carry no op) stay unchanged; instance hooks keep `middleware` and the
handler hook keeps `request_handler.fastify`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@msonnb

msonnb commented Jul 30, 2026

Copy link
Copy Markdown
Member Author

bugbot run

@msonnb msonnb changed the title feat(node)!: Use middleware span op for web-server middleware feat!: Use middleware span op for web-server middleware Jul 30, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 26befb7. Configure here.

Comment thread packages/core/src/integrations/express/patch-layer.ts
@msonnb
msonnb force-pushed the ms/js-3105-middleware-span-op branch from 26befb7 to e938d57 Compare July 30, 2026 12:25
@msonnb
msonnb marked this pull request as ready for review July 31, 2026 07:19
@msonnb
msonnb requested review from a team as code owners July 31, 2026 07:19
@msonnb
msonnb requested review from isaacs, mydea, nicohrubec and s1gr1d and removed request for a team July 31, 2026 07:19
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