Skip to content

fix(cloudflare): Prevent AI provider skips - #22719

Merged
JPeer264 merged 1 commit into
developfrom
jp/fix-skip-instrument
Jul 28, 2026
Merged

fix(cloudflare): Prevent AI provider skips#22719
JPeer264 merged 1 commit into
developfrom
jp/fix-skip-instrument

Conversation

@JPeer264

Copy link
Copy Markdown
Member

When running on agents or any other SDK on Cloudflare it could be that users use Vercel AI. When this happens it could be that workers-ai and ai spans are generating two spans for LLM calls. With _INTERNAL_skipAiProviderWrapping we can actually prevent this from happening: https://sentry-sdks.sentry.io/explore/traces/trace/e532a314e3b745de974f2b04cd745975/

@JPeer264 JPeer264 self-assigned this Jul 27, 2026
@JPeer264
JPeer264 requested review from a team as code owners July 27, 2026 16:50
@JPeer264
JPeer264 requested review from andreiborza and isaacs and removed request for a team July 27, 2026 16:50
Comment thread packages/server-utils/src/vercel-ai/vercel-ai-dc-subscriber.ts
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.02 kB - -
@sentry/browser - with treeshaking flags 26.46 kB - -
@sentry/browser (incl. Tracing) 46.54 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 47.46 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.3 kB - -
@sentry/browser (incl. Tracing, Replay) 85.87 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.51 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 90.58 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 103.22 kB - -
@sentry/browser (incl. Feedback) 45.2 kB - -
@sentry/browser (incl. sendFeedback) 32.82 kB - -
@sentry/browser (incl. FeedbackAsync) 37.86 kB - -
@sentry/browser (incl. Metrics) 29.12 kB - -
@sentry/browser (incl. Logs) 29.34 kB - -
@sentry/browser (incl. Metrics & Logs) 30.05 kB - -
@sentry/react 29.8 kB - -
@sentry/react (incl. Tracing) 48.85 kB - -
@sentry/vue 33.97 kB - -
@sentry/vue (incl. Tracing) 48.53 kB - -
@sentry/svelte 28.04 kB - -
CDN Bundle 30.32 kB - -
CDN Bundle (incl. Tracing) 47.71 kB - -
CDN Bundle (incl. Logs, Metrics) 31.9 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.08 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 71.17 kB - -
CDN Bundle (incl. Tracing, Replay) 85.31 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.61 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.12 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.39 kB - -
CDN Bundle - uncompressed 90.26 kB - -
CDN Bundle (incl. Tracing) - uncompressed 143.22 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.97 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 147.2 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 219.73 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 262.47 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 266.44 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 276.18 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 280.13 kB - -
@sentry/nextjs (client) 51.41 kB - -
@sentry/sveltekit (client) 47.01 kB - -
@sentry/core/server 79.67 kB +0.06% +47 B 🔺
@sentry/core/browser 51.54 kB - -
@sentry/node 112.51 kB +0.04% +37 B 🔺
@sentry/node (incl. diagnostics channel injection) 156.67 kB +0.03% +35 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 166 B - -
@sentry/node - without tracing 62.01 kB -0.01% -1 B 🔽
@sentry/aws-serverless 72.29 kB +0.01% +1 B 🔺
@sentry/cloudflare (withSentry) - minified 196.61 kB +0.16% +307 B 🔺
@sentry/cloudflare (withSentry) 483.96 kB +0.18% +823 B 🔺

View base workflow run

@JPeer264
JPeer264 requested a review from nicohrubec July 27, 2026 17:48

@andreiborza andreiborza 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 but an integration or e2e test would be nicer for validating the skips. As is feels a bit contrived, but feel free to ignore if you're confident this all works.

Comment on lines +70 to +71
// TODO(v11): export the constant from server-utils and import it here instead.
const WORKERS_AI_INTEGRATION_NAME = 'WorkersAI';

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.

q: Why is this a todo? Can't we do that now? We are in v11.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes we can. I just wanted to keep things easier for backports for now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In a follow up I can move everything over to server-utils

@JPeer264

Copy link
Copy Markdown
Member Author

As is feels a bit contrived, but feel free to ignore if you're confident this all works.

For now integration nor e2e tests would be valuable as workers-ai doesn't have a nice mock. And if we mock, then we just test the mock again

@JPeer264
JPeer264 merged commit f40c412 into develop Jul 28, 2026
539 of 543 checks passed
@JPeer264
JPeer264 deleted the jp/fix-skip-instrument branch July 28, 2026 14:09
JPeer264 added a commit that referenced this pull request Jul 28, 2026
JPeer264 added a commit that referenced this pull request Jul 28, 2026
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