Skip to content

Conversation

@jaffrepaul
Copy link
Contributor

@jaffrepaul jaffrepaul commented Feb 9, 2026

DESCRIBE YOUR PR

Middleware spans in Sentry's Edge runtime instrumentation don't receive normalizedRequest, making traffic classification impossible. These spans were being classified as "unknown", inflating that metric significantly (~50% of all spans).

Since every middleware span has a corresponding page span (e.g., "middleware GET /path" → "GET /path") that does receive full request context, we can safely skip sampling middleware spans without losing any classification data.

Root cause: Discovered via local debugging that samplingContext.normalizedRequest is always undefined for spans named middleware GET /..., while the corresponding GET /... spans have full headers including user-agent.

IS YOUR CHANGE URGENT?

  • Urgent deadline (GA date, etc.)
  • Other deadline
  • None: Not urgent, can wait up to 1 week+

SLA

  • Teamwork makes the dream work, so please add a reviewer to your PRs.
  • Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it.

PRE-MERGE CHECKLIST

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs (subject matter experts)
  • PR was reviewed and approved by a member of the Sentry docs team

Middleware spans in Sentry's Edge runtime instrumentation don't receive
normalizedRequest, making traffic classification impossible. These spans
were being classified as "unknown", inflating that metric.

Since every middleware span has a corresponding page span (e.g.,
"middleware GET /path" → "GET /path") that does receive full request
context, we can safely skip middleware spans without losing data.

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Feb 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
develop-docs Ready Ready Preview, Comment Feb 9, 2026 11:54pm
sentry-docs Ready Ready Preview, Comment Feb 9, 2026 11:54pm

Request Review

@jaffrepaul jaffrepaul marked this pull request as ready for review February 9, 2026 23:45
@jaffrepaul jaffrepaul marked this pull request as draft February 9, 2026 23:48
Copy link

@cursor cursor bot left a comment

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.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

// (e.g., "GET /path") will capture the same request with full classification data.
if (spanName.startsWith('middleware ')) {
return 0;
}
Copy link

Choose a reason for hiding this comment

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

Skipped middleware spans miss metric counter emission

Low Severity

Every other return path in tracesSampler emits a Sentry.metrics.count('docs.trace.sampled', ...) call before returning — including the bot path that also returns 0. The new middleware early-return skips this metric entirely. Since the PR notes middleware spans account for ~50% of all spans, this creates a significant observability gap in docs.trace.sampled volume tracking with no way to distinguish "we intentionally dropped these" from "something broke."

Fix in Cursor Fix in Web

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