Skip to content

feat!: Use function span op for terminal request handlers - #22871

Open
msonnb wants to merge 7 commits into
developfrom
ms/js-3105-handler-function-op
Open

feat!: Use function span op for terminal request handlers#22871
msonnb wants to merge 7 commits into
developfrom
ms/js-3105-handler-function-op

Conversation

@msonnb

@msonnb msonnb commented Jul 30, 2026

Copy link
Copy Markdown
Member

Collapses the terminal request-handler span ops across the server frameworks to the cross-framework function op, so every "this is where the user's route handler runs" span shares one op regardless of framework.

Hono’s app.request() is an internal HTTP dispatch (one sub-app calling another in-process), so it is semantically an inbound server request and is now traced as http.server

Part of #22446

msonnb and others added 5 commits July 30, 2026 11:47
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>
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>
Migrate the terminal request-handler span ops across the server
integrations to the cross-framework `function` op, and trace Hono's
internal `app.request()` dispatch as an `http.server` span:

- express: `request_handler.express` -> `function`
- fastify: `request_handler.fastify` -> `function`
- elysia:  `request_handler.elysia`  -> `function`
- nestjs:  `handler.nestjs`          -> `function`
- hono:    `hono.request`            -> `http.server`

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.5 kB +0.04% +26 B 🔺
@sentry/core/browser 51.58 kB - -
@sentry/node 121.28 kB +0.06% +68 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 166 B - -
@sentry/node - without tracing 84.77 kB - -
@sentry/aws-serverless 93.02 kB - -
@sentry/cloudflare (withSentry) - minified 197.59 kB - -
@sentry/cloudflare (withSentry) 485.77 kB - -

View base workflow run

@msonnb msonnb changed the title feat(node)!: Use function span op for terminal request handlers feat!: Use function span op for terminal request handlers Jul 30, 2026
@msonnb
msonnb marked this pull request as ready for review July 31, 2026 07:35
@msonnb
msonnb requested review from a team as code owners July 31, 2026 07:35
@msonnb
msonnb requested review from isaacs, mydea, nicohrubec and s1gr1d and removed request for a team July 31, 2026 07:35
A plugin-registered hapi route runs the user's request handler, so it is a
terminal handler like the express/fastify/hono routes in this migration.
Map `plugin.hapi` to the cross-framework `function` op; `router.hapi` and
`server.ext.hapi` (framework routing/extension lifecycle) keep their ops.

Op is set via the `sentry.op` attribute only; `hapi.type` is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Base automatically changed from ms/js-3105-middleware-span-op to develop July 31, 2026 11:17
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