Skip to content

feat(cloudflare): Add batch, exec, and withSession D1 instrumentation#21292

Open
JPeer264 wants to merge 3 commits into
developfrom
jp/missing-d1-instrumentations
Open

feat(cloudflare): Add batch, exec, and withSession D1 instrumentation#21292
JPeer264 wants to merge 3 commits into
developfrom
jp/missing-d1-instrumentations

Conversation

@JPeer264

@JPeer264 JPeer264 commented Jun 2, 2026

Copy link
Copy Markdown
Member

This PR does 2 things:

  1. It adds missing methods of D1 and adds a span to each
    • batch, exec, and withSession. withSession is not doing anything as per spec, but instruments its return values prepare and batch
  2. Some Sentry convention updates

AI generated text:

Instrument db.batch(), db.exec(), and db.withSession() methods
that were previously not covered by D1 instrumentation.

@JPeer264 JPeer264 self-assigned this Jun 2, 2026
@JPeer264 JPeer264 force-pushed the jp/missing-d1-instrumentations branch from dc4ec0c to c7c19eb Compare June 2, 2026 12:55
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.45 kB - -
@sentry/browser - with treeshaking flags 25.88 kB - -
@sentry/browser (incl. Tracing) 45.88 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.11 kB - -
@sentry/browser (incl. Tracing, Profiling) 50.65 kB - -
@sentry/browser (incl. Tracing, Replay) 85.08 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 74.68 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 89.78 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 102.44 kB - -
@sentry/browser (incl. Feedback) 44.62 kB - -
@sentry/browser (incl. sendFeedback) 32.25 kB - -
@sentry/browser (incl. FeedbackAsync) 37.38 kB - -
@sentry/browser (incl. Metrics) 28.52 kB - -
@sentry/browser (incl. Logs) 28.76 kB - -
@sentry/browser (incl. Metrics & Logs) 29.45 kB - -
@sentry/react 29.25 kB - -
@sentry/react (incl. Tracing) 48.17 kB - -
@sentry/vue 32.56 kB - -
@sentry/vue (incl. Tracing) 47.74 kB - -
@sentry/svelte 27.48 kB - -
CDN Bundle 29.86 kB - -
CDN Bundle (incl. Tracing) 48.28 kB - -
CDN Bundle (incl. Logs, Metrics) 31.4 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.58 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.71 kB - -
CDN Bundle (incl. Tracing, Replay) 85.61 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.88 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.46 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.71 kB - -
CDN Bundle - uncompressed 88.8 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.04 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 93.5 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 150.02 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.33 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 264.91 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 268.87 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 278.61 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 282.56 kB - -
@sentry/nextjs (client) 50.58 kB - -
@sentry/sveltekit (client) 46.27 kB - -
@sentry/core/server 76.14 kB - -
@sentry/core/browser 63.29 kB - -
@sentry/node-core 61.84 kB +0.01% +1 B 🔺
@sentry/node 128.29 kB - -
@sentry/node - without tracing 74.22 kB - -
@sentry/aws-serverless 85.47 kB +0.01% +1 B 🔺
@sentry/cloudflare (withSentry) - minified 175.39 kB +0.53% +909 B 🔺
@sentry/cloudflare (withSentry) 438.42 kB +0.44% +1.89 kB 🔺

View base workflow run

Base automatically changed from jp/deprecate-d1-instrument-via-env to develop June 3, 2026 13:40
Instrument `db.batch()`, `db.exec()`, and `db.withSession()` methods
that were previously not covered by D1 instrumentation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@JPeer264 JPeer264 force-pushed the jp/missing-d1-instrumentations branch from c7c19eb to c4b6af2 Compare June 15, 2026 16:20
@JPeer264 JPeer264 marked this pull request as ready for review June 16, 2026 09:14
@JPeer264 JPeer264 requested a review from a team as a code owner June 16, 2026 09:14
@JPeer264 JPeer264 requested review from andreiborza and mydea and removed request for a team June 16, 2026 09:14

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c4b6af2. Configure here.

Comment thread dev-packages/cloudflare-integration-tests/suites/d1/test.ts
Comment thread packages/cloudflare/src/instrumentations/worker/instrumentD1.ts
@github-actions

Copy link
Copy Markdown
Contributor

👋 @mydea, @andreiborza — Please review this PR when you get a chance!

const runner = createRunner(__dirname)
.ignore('event')
.expect((envelope: Envelope) => {
if (envelopeItemType(envelope) !== 'transaction') return;

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: this would silently pass the test right? seems a bit weird. I think we should just hard fail if we don't have a transaction here, no?

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