Skip to content

feat(nextjs): Remove tracing from middleware wrappers - #18456

Merged
logaretm merged 1 commit into
developfrom
awad/js-1208-remove-tracing-from-middleware-template
Jul 24, 2026
Merged

feat(nextjs): Remove tracing from middleware wrappers#18456
logaretm merged 1 commit into
developfrom
awad/js-1208-remove-tracing-from-middleware-template

Conversation

@logaretm

@logaretm logaretm commented Dec 10, 2025

Copy link
Copy Markdown
Member

closes #18308

@linear

linear Bot commented Dec 10, 2025

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Dec 10, 2025

Copy link
Copy Markdown
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,811 - 8,432 +4%
GET With Sentry 1,765 20% 1,645 +7%
GET With Sentry (error only) 6,081 69% 5,458 +11%
POST Baseline 1,210 - 1,169 +4%
POST With Sentry 602 50% 550 +9%
POST With Sentry (error only) 1,080 89% 1,016 +6%
MYSQL Baseline 3,338 - 3,241 +3%
MYSQL With Sentry 480 14% 368 +30%
MYSQL With Sentry (error only) 2,748 82% 2,593 +6%

View base workflow run

@logaretm
logaretm force-pushed the awad/js-1208-remove-tracing-from-middleware-template branch 2 times, most recently from 1239a7e to 7f472ff Compare December 16, 2025 20:46
@chargome chargome added this to the 11.0.0 milestone Jan 8, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you apply the label PR: no-auto-close I will leave it alone ... forever!

@logaretm
logaretm force-pushed the awad/js-1208-remove-tracing-from-middleware-template branch 2 times, most recently from 4ab8735 to 098a86b Compare July 21, 2026 15:28
@logaretm
logaretm changed the base branch from develop to awad/drop-nextjs-13-e2e-tests July 21, 2026 15:28
@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.95 kB - -
@sentry/browser - with treeshaking flags 26.39 kB - -
@sentry/browser (incl. Tracing) 46.41 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.18 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.21 kB - -
@sentry/browser (incl. Tracing, Replay) 85.69 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.33 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 90.4 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 103.06 kB - -
@sentry/browser (incl. Feedback) 45.13 kB - -
@sentry/browser (incl. sendFeedback) 32.74 kB - -
@sentry/browser (incl. FeedbackAsync) 37.8 kB - -
@sentry/browser (incl. Metrics) 29.04 kB - -
@sentry/browser (incl. Logs) 29.26 kB - -
@sentry/browser (incl. Metrics & Logs) 29.97 kB - -
@sentry/react 29.75 kB - -
@sentry/react (incl. Tracing) 48.71 kB - -
@sentry/vue 33.38 kB - -
@sentry/vue (incl. Tracing) 48.4 kB - -
@sentry/svelte 27.97 kB - -
CDN Bundle 30.28 kB - -
CDN Bundle (incl. Tracing) 48.26 kB - -
CDN Bundle (incl. Logs, Metrics) 31.85 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.58 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 71.13 kB - -
CDN Bundle (incl. Tracing, Replay) 85.83 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.14 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.6 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.89 kB - -
CDN Bundle - uncompressed 90.15 kB - -
CDN Bundle (incl. Tracing) - uncompressed 145.22 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.86 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 149.2 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 219.62 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 264.46 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 268.42 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 278.16 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 282.11 kB - -
@sentry/nextjs (client) 51.24 kB - -
@sentry/sveltekit (client) 46.84 kB - -
@sentry/core/server 80.05 kB - -
@sentry/core/browser 52.01 kB - -
@sentry/node 123.14 kB - -
@sentry/node (incl. diagnostics channel injection) 167.14 kB - -
@sentry/node/import (ESM hook with diagnostics-channel injection) 166 B - -
@sentry/node - without tracing 73.3 kB -0.01% -1 B 🔽
@sentry/aws-serverless 82.81 kB -0.01% -1 B 🔽
@sentry/cloudflare (withSentry) - minified 197.05 kB - -
@sentry/cloudflare (withSentry) 484.73 kB - -

View base workflow run

@logaretm
logaretm force-pushed the awad/js-1208-remove-tracing-from-middleware-template branch from 098a86b to cd33bb0 Compare July 21, 2026 15:42
@logaretm
logaretm force-pushed the awad/js-1208-remove-tracing-from-middleware-template branch from cd33bb0 to 64ce1ee Compare July 21, 2026 18:19
Base automatically changed from awad/drop-nextjs-13-e2e-tests to develop July 21, 2026 18:38
logaretm added a commit that referenced this pull request Jul 21, 2026
Drops the dedicated `nextjs-13` e2e test app (and its `canary.yml`
matrix entry) ahead of removing Next.js 13 support in v11.

Also removes the `isNext13` guards and the `nextjsVersion.ts` helpers
from the pages-dir and app-dir suites. Those were dead code: both apps
are pinned to Next 14, so the guarded branches never ran. Unwrapping
them is behavior-preserving.

Base of a stack. The middleware wrapper change in #18456 sits on top.
@logaretm
logaretm force-pushed the awad/js-1208-remove-tracing-from-middleware-template branch from 64ce1ee to 03043ca Compare July 21, 2026 18:38
@logaretm
logaretm marked this pull request as ready for review July 21, 2026 18:38
@logaretm
logaretm requested a review from a team as a code owner July 21, 2026 18:38
@logaretm
logaretm requested review from chargome and nicohrubec and removed request for a team July 21, 2026 18:38

@nicohrubec nicohrubec left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

Drops the manually-created span from the middleware wrapper. On Next.js
14+ the native OTel middleware span (normalized by enhanceMiddlewareRootSpan)
already produces the middleware transaction, so the wrapper only forks an
isolation scope, binds it to the native root span, captures errors, and
flushes. Keeps withIsolationScope + setCapturedScopesOnSpan so per-request
isolation still holds and global-scope data does not leak into the
middleware transaction.
@logaretm
logaretm force-pushed the awad/js-1208-remove-tracing-from-middleware-template branch from 03043ca to 33b6d7e Compare July 24, 2026 13:27
@logaretm
logaretm merged commit b91d03b into develop Jul 24, 2026
79 checks passed
@logaretm
logaretm deleted the awad/js-1208-remove-tracing-from-middleware-template branch July 24, 2026 13:57
chargome added a commit that referenced this pull request Jul 27, 2026
Aligns the Next.js middleware span op with the `@sentry/conventions`
`WEB_SERVER_MIDDLEWARE_SPAN_OP` (`middleware`), replacing the previous
`http.server.middleware`. The mixed `http.server`-family op was problematic
for span streaming and description inference.

Also adds regression coverage asserting the middleware wrapper does not start
its own span (the duplicate was already removed in #18456).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
chargome added a commit that referenced this pull request Jul 27, 2026
Aligns the Next.js middleware span op with the `@sentry/conventions`
`middleware`, replacing the previous `http.server.middleware`.

The duplicate middleware span this issue also described was already
resolved separately in #18456 (the build-time wrapper no longer starts
its own span); this PR adds the regression test coverage that was
missing there.

closes #22636

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove tracing from Middleware wrapper template

3 participants