Skip to content

feat(cloudflare): Auto-instrument Workers AI binding via env instrumentation#22126

Draft
JPeer264 wants to merge 1 commit into
jp/cloudflare-workers-aifrom
jp/cloudflare-workers-ai-cf
Draft

feat(cloudflare): Auto-instrument Workers AI binding via env instrumentation#22126
JPeer264 wants to merge 1 commit into
jp/cloudflare-workers-aifrom
jp/cloudflare-workers-ai-cf

Conversation

@JPeer264

@JPeer264 JPeer264 commented Jul 9, 2026

Copy link
Copy Markdown
Member

This auto-wraps workers-ai bindings via instrumentEnv. Unfortunately locally there is no AI binding available and would require an actual LLM on Cloudflare, so in the integration tests there is only a MockAi. However, the autobinding is tested via unit tests and have the same pattern as the other instrumentations.

…ntation

Detect the Workers AI binding (env.AI) in instrumentEnv via duck-typing
(run + gateway + toMarkdown) and wrap it automatically, matching how D1,
R2, and Queue bindings are instrumented. Manual wrapping via
instrumentWorkersAiClient remains available for custom options and is now
guarded against double-wrapping. Also removes the unused
WORKERS_AI_INTEGRATION_NAME constant and aligns the integration test
wrangler config with sibling suites (nodejs_als).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@JPeer264 JPeer264 self-assigned this Jul 9, 2026
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.59 kB - -
@sentry/browser - with treeshaking flags 26.03 kB - -
@sentry/browser (incl. Tracing) 46.34 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.13 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.12 kB - -
@sentry/browser (incl. Tracing, Replay) 85.61 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.26 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 90.32 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 102.97 kB - -
@sentry/browser (incl. Feedback) 44.76 kB - -
@sentry/browser (incl. sendFeedback) 32.38 kB - -
@sentry/browser (incl. FeedbackAsync) 37.51 kB - -
@sentry/browser (incl. Metrics) 28.67 kB - -
@sentry/browser (incl. Logs) 28.91 kB - -
@sentry/browser (incl. Metrics & Logs) 29.59 kB - -
@sentry/react 29.38 kB - -
@sentry/react (incl. Tracing) 48.61 kB - -
@sentry/vue 33.03 kB - -
@sentry/vue (incl. Tracing) 48.24 kB - -
@sentry/svelte 27.61 kB - -
CDN Bundle 30 kB - -
CDN Bundle (incl. Tracing) 48.32 kB - -
CDN Bundle (incl. Logs, Metrics) 31.57 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.64 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.81 kB - -
CDN Bundle (incl. Tracing, Replay) 85.84 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.14 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.64 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.92 kB - -
CDN Bundle - uncompressed 89.35 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.1 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.05 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 150.07 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.75 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.27 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 269.23 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 278.97 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 282.92 kB - -
@sentry/nextjs (client) 51.16 kB - -
@sentry/sveltekit (client) 46.75 kB - -
@sentry/core/server 79.33 kB +1.18% +918 B 🔺
@sentry/core/browser 65.69 kB +1.47% +948 B 🔺
@sentry/node-core 62.72 kB - -
@sentry/node 125.33 kB -0.03% -31 B 🔽
@sentry/node (incl. diagnostics channel injection) 134.97 kB -0.03% -35 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 69.95 kB - -
@sentry/node/light 50.72 kB +0.01% +1 B 🔺
@sentry/node - without tracing 74.05 kB - -
@sentry/aws-serverless 85.5 kB - -
⛔️ @sentry/cloudflare (withSentry) - minified (max: 187.39 kB) 193.67 kB +6.59% +11.96 kB 🔺
⛔️ @sentry/cloudflare (withSentry) (max: 455.68 kB) 477.01 kB +6.21% +27.85 kB 🔺

View base workflow run

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