Skip to content

fix(cloudflare): Skip binding instrumentation work when spans are not sent - #24655

Open
JPeer264 wants to merge 1 commit into
developfrom
jp/cloudflare-sql-skip-without-tracing
Open

JPeer264 wants to merge 1 commit into
developfrom
jp/cloudflare-sql-skip-without-tracing

Conversation

@JPeer264

Copy link
Copy Markdown
Member

The binding instrumentations (DO SQL, DO KV, sync KV, D1, R2, queue producer, agent callable RPC) built span data on every call, even when the SDK was disabled, had no DSN, had no tracing configured, or ran under an unsampled parent. On SQL-heavy Durable Objects the per-query sanitizing alone showed up as a large CPU regression with tracesSampleRate: 0.

They now call the original method directly in these cases. D1 keeps adding breadcrumbs while the SDK is enabled, and sanitizes the query only when a statement runs. setAlarm keeps its span path, because it stores the span context for the alarm trace link.

We don't really need to set the NonRecordingSpan for these, so it is safe to skip startSpan entirely

@JPeer264 JPeer264 self-assigned this Sep 23, 2026
@JPeer264
JPeer264 force-pushed the jp/cloudflare-sql-skip-without-tracing branch 5 times, most recently from 883e804 to db6f184 Compare September 25, 2026 10:51
…be sent

The binding instrumentations (DO SQL, DO KV, sync KV, D1, R2, queue producer,
agent callable RPC) built span data on every call, even when the SDK was
disabled, had no DSN, had no tracing configured, or ran under an unsampled
parent. On SQL-heavy Durable Objects the per-query sanitizing alone showed up
as a large CPU regression with `tracesSampleRate: 0`.

They now call the original method directly in these cases. D1 keeps adding
breadcrumbs while the SDK is enabled, and sanitizes the query only when a
statement runs. `setAlarm` keeps its span path, because it stores the span
context for the alarm trace link.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JPeer264
JPeer264 force-pushed the jp/cloudflare-sql-skip-without-tracing branch from db6f184 to 28885a9 Compare September 25, 2026 10:57
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 29.24 kB - -
@sentry/browser - with treeshaking flags 27.5 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.4 kB - -
@sentry/browser (incl. Tracing) 51.15 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 51.17 kB - -
@sentry/browser (incl. Tracing, Profiling) 54.18 kB - -
@sentry/browser (incl. Tracing, Replay) 90.76 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 79.86 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 95.46 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 108.41 kB - -
@sentry/browser (incl. Feedback) 46.76 kB - -
@sentry/browser (incl. sendFeedback) 34.3 kB - -
@sentry/browser (incl. FeedbackAsync) 39.41 kB - -
@sentry/browser (incl. Metrics) 30.25 kB - -
@sentry/browser (incl. Logs) 30.51 kB - -
@sentry/browser (incl. Metrics & Logs) 31.18 kB - -
@sentry/react 31 kB - -
@sentry/react (incl. Tracing) 53.45 kB - -
@sentry/vue 36.74 kB - -
@sentry/vue (incl. Tracing) 53.7 kB - -
@sentry/svelte 29.26 kB - -
CDN Bundle 30.93 kB - -
CDN Bundle (incl. Tracing) 51.69 kB - -
CDN Bundle (incl. Logs, Metrics) 33.2 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 53.66 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.92 kB - -
CDN Bundle (incl. Tracing, Replay) 89.28 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 91.25 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 95.45 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 97.42 kB - -
CDN Bundle - uncompressed 91.4 kB - -
CDN Bundle (incl. Tracing) - uncompressed 153.77 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.97 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 159.73 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 227.54 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 273.5 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 279.44 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 287.2 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 293.13 kB - -
@sentry/nextjs (client) 55.77 kB - -
@sentry/sveltekit (client) 51.59 kB - -
@sentry/core/server 39.95 kB - -
@sentry/core/browser 13.63 kB - -
@sentry/node 133.9 kB +0.01% +6 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 82.43 kB - -
@sentry/node - without tracing 90.45 kB +0.02% +13 B 🔺
@sentry/node - without channel injection 112.41 kB +0.01% +10 B 🔺
@sentry/aws-serverless 98.72 kB +0.01% +4 B 🔺
@sentry/cloudflare (withSentry) - minified 206.9 kB +0.2% +410 B 🔺
@sentry/cloudflare (withSentry) 515.14 kB +0.28% +1.41 kB 🔺

View base workflow run

@JPeer264
JPeer264 marked this pull request as ready for review September 25, 2026 16:01
@JPeer264
JPeer264 requested a review from a team as a code owner September 25, 2026 16:01
@JPeer264
JPeer264 requested review from andreiborza, isaacs and mydea and removed request for a team September 25, 2026 16:01

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.

1 participant