Skip to content

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

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

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 from 206dc01 to 5ab1e48 Compare September 23, 2026 14:02
…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 5ab1e48 to 7cc6e5f Compare September 23, 2026 14:10

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