Skip to content

feat(nitro): Report a single http.server span per request - #25295

Open
mydea wants to merge 2 commits into
feat/nitro-single-integrationfrom
feat/nitro-single-http-server-span
Open

mydea wants to merge 2 commits into
feat/nitro-single-integrationfrom
feat/nitro-single-http-server-span

Conversation

@mydea

@mydea mydea commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

A Nitro request currently produces three nested http.server spans: the runtime's own (Node http, Bun.serve, Deno.serve, Cloudflare's request wrapper), then one from srvx's srvx.request channel, then one from h3's h3.request route channel. The nested two add nothing the root does not already carry: srvx only duplicates the URL and header attributes (with a wrong server.port, the configured 0 rather than the bound port), and h3's route and params were already being copied onto the root.

Now the root is the only http.server span:

  • srvx creates or enriches, like the Hono integration: it skips its span when the root is already an http.server span, and only creates the root otherwise (e.g. @sentry/node on Bun, where no runtime instrumentation creates one). server.port now reports the bound port in that case.
  • h3 route handlers get a handler span instead, the same op the Express integration uses for request handlers, so the time spent in the handler itself stays visible.
  • Middleware spans (h3 and srvx) are unchanged and now sit directly under the root.

This is a visible change for existing @sentry/nitro users: the auto.http.nitro.srvx and auto.http.nitro.h3 http.server spans go away, so queries or alerts on them need to move to the root span or the handler span.

🤖 Generated with Claude Code

@mydea
mydea added this pull request to stack #24913 October 12, 2026 14:08

@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.

Stale Bugbot comment from a previous run.

Comment thread dev-packages/node-integration-tests/suites/tracing/nitro/test.ts Outdated
@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.83 kB - -
@sentry/browser - with treeshaking flags 27.96 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.87 kB - -
@sentry/browser (incl. Tracing) 52.02 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.02 kB - -
@sentry/browser (incl. Tracing, Profiling) 54.96 kB - -
@sentry/browser (incl. Tracing, Replay) 91.75 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 80.62 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 96.47 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 109.43 kB - -
@sentry/browser (incl. Feedback) 47.35 kB - -
@sentry/browser (incl. sendFeedback) 34.89 kB - -
@sentry/browser (incl. FeedbackAsync) 40 kB - -
@sentry/browser (incl. Metrics) 30.85 kB - -
@sentry/browser (incl. Logs) 31.13 kB - -
@sentry/browser (incl. Metrics & Logs) 31.78 kB - -
@sentry/react 31.64 kB - -
@sentry/react (incl. Tracing) 54.34 kB - -
@sentry/vue 37.98 kB - -
@sentry/vue (incl. Tracing) 54.95 kB - -
@sentry/svelte 29.86 kB - -
@sentry/remix (Remix 3 client bundle) 57.02 kB - -
CDN Bundle 31.56 kB - -
CDN Bundle (incl. Tracing) 52.52 kB - -
CDN Bundle (incl. Logs, Metrics) 33.77 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 54.46 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74.7 kB - -
CDN Bundle (incl. Tracing, Replay) 90.19 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 92.11 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 96.34 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 98.28 kB - -
CDN Bundle - uncompressed 92.98 kB - -
CDN Bundle (incl. Tracing) - uncompressed 155.83 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 99.52 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 161.79 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 229.56 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 276 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 281.94 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 289.7 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 295.63 kB - -
@sentry/nextjs (client) 56.75 kB - -
@sentry/sveltekit (client) 52.41 kB - -
@sentry/core/server 41.12 kB - -
@sentry/core/browser 13.81 kB - -
@sentry/node 153.76 kB +1.18% +1.79 kB 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.8 kB +0.03% +17 B 🔺
@sentry/node - without tracing 96.36 kB +1.94% +1.83 kB 🔺
@sentry/node - without channel injection 131.95 kB +1.37% +1.78 kB 🔺
@sentry/aws-serverless 104.55 kB +1.82% +1.86 kB 🔺
@sentry/cloudflare (withSentry) - minified 210.38 kB - -
@sentry/cloudflare (withSentry) 521.61 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 228.06 kB - -

View base workflow run

@mydea
mydea marked this pull request as ready for review October 13, 2026 07:44
@mydea
mydea requested a review from a team as a code owner October 13, 2026 07:44
@mydea
mydea requested review from andreiborza and isaacs and removed request for a team October 13, 2026 07:44
@mydea
mydea force-pushed the feat/nitro-single-http-server-span branch 2 times, most recently from 9d4396f to 715d8cd Compare October 14, 2026 06:48

@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 715d8cd. Configure here.

[SENTRY_ORIGIN]: 'auto.http.nitro.srvx',
[SENTRY_OP]: data.middleware ? MIDDLEWARE : HTTP_SERVER,
'server.port': data.server.options.port,
'server.port': getServerPort(data.server),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hardcoded server.port attribute name

Low Severity

The srvx span still writes server.port as a string literal. @sentry/conventions/attributes already exports SERVER_PORT for this, and the Node HTTP server instrumentation uses that constant for the same field. Flagged because the review rules require conventions constants instead of hard-coded attribute names.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 715d8cd. Configure here.

@mydea
mydea force-pushed the feat/nitro-single-http-server-span branch from 715d8cd to 525ca97 Compare October 14, 2026 07:31
@mydea
mydea requested a review from a team as a code owner October 14, 2026 07:31
@mydea
mydea requested review from nicohrubec and s1gr1d and removed request for a team October 14, 2026 07:31
@mydea
mydea removed this pull request from stack #24913 October 14, 2026 07:32
@mydea
mydea changed the base branch from feat/nitro-anchor-both-on-h3 to feat/nitro-single-integration October 14, 2026 07:32
@mydea
mydea added this pull request to stack #25350 October 14, 2026 07:32
mydea and others added 2 commits October 14, 2026 09:43
The srvx and h3 tracing channels each opened another http.server span below
the one the runtime already creates, duplicating its attributes. srvx now
only creates the root span when the runtime has not, and the h3 route
handler gets a handler span that times the handler itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mydea
mydea force-pushed the feat/nitro-single-http-server-span branch from 525ca97 to 1cfc785 Compare October 14, 2026 07:44

This branch has not been deployed

No deployments
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.

2 participants