@danieljvdm/dev-kit 1.0.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/package.json +1 -1
- package/skill-sources.jsonc +2 -33
- package/skill-sources.lock.json +15 -117
- package/skills/animate/LICENSE +21 -0
- package/skills/animate/NOTICE +10 -0
- package/skills/animate/SKILL.md +34 -0
- package/skills/animate/references/gestures.md +27 -0
- package/skills/animate/references/glossary.md +136 -0
- package/skills/animate/references/implementation.md +22 -0
- package/skills/animate/references/opportunities.md +18 -0
- package/skills/animate/references/principles.md +48 -0
- package/skills/animate/references/review.md +19 -0
- package/skills/cloudflare-workers/LICENSE +202 -0
- package/skills/cloudflare-workers/NOTICE +9 -0
- package/skills/cloudflare-workers/SKILL.md +26 -0
- package/skills/cloudflare-workers/references/durable-objects.md +68 -0
- package/skills/cloudflare-workers/references/sandbox.md +48 -0
- package/skills/cloudflare-workers/references/workers.md +63 -0
- package/skills/cloudflare-workers/references/wrangler.md +56 -0
- package/skills/design-ui/LICENSE +21 -0
- package/skills/design-ui/NOTICE +8 -0
- package/skills/design-ui/SKILL.md +29 -0
- package/skills/design-ui/references/appearance.md +22 -0
- package/skills/design-ui/references/components.md +33 -0
- package/skills/design-ui/references/exploration.md +50 -0
- package/skills/design-ui/references/libraries.md +39 -0
- package/skills/design-ui/references/themes.md +23 -0
- package/skills/dev-kit/SKILL.md +19 -38
- package/skills/dev-kit/references/cloudflare-worker-api.md +1 -1
- package/skills/dev-kit/references/skills.md +2 -2
- package/skills/effect-development/SKILL.md +27 -0
- package/skills/effect-development/agents/openai.yaml +4 -0
- package/skills/effect-development/references/api/index.md +32 -0
- package/skills/effect-development/references/api/schema-codecs.md +15 -0
- package/skills/{build-effect-apis/references → effect-development/references/api}/verification.md +10 -5
- package/skills/{effect-architecture-audit/SKILL.md → effect-development/references/architecture/index.md} +1 -6
- package/skills/{effect-atom-state/references → effect-development/references/atom}/effect-atom-client.md +8 -6
- package/skills/{effect-atom-state/references → effect-development/references/atom}/effect-atom-testing.md +7 -2
- package/skills/effect-development/references/atom/index.md +40 -0
- package/skills/{build-effect-clis/references → effect-development/references/cli}/entrypoints-and-testing.md +6 -2
- package/skills/effect-development/references/cli/index.md +39 -0
- package/skills/effect-development/references/setup.md +15 -0
- package/skills/open-pull-request/SKILL.md +10 -70
- package/skills/open-pull-request/references/evidence.md +22 -0
- package/skills/open-pull-request/references/explanation.md +21 -0
- package/skills/open-pull-request/references/publication.md +21 -0
- package/skills/sentry/LICENSE +202 -0
- package/skills/sentry/LICENSE-UPSTREAM +21 -0
- package/skills/sentry/NOTICE +14 -0
- package/skills/sentry/SKILL.md +33 -0
- package/skills/sentry/references/alert-payloads.md +105 -0
- package/skills/sentry/references/alerts.md +17 -0
- package/skills/sentry/references/artifacts.md +25 -0
- package/skills/sentry/references/auth-token.md +65 -0
- package/skills/sentry/references/concepts/ai-monitoring.md +131 -0
- package/skills/sentry/references/concepts/choosing-a-signal.md +78 -0
- package/skills/sentry/references/concepts/crons.md +50 -0
- package/skills/sentry/references/concepts/data-scrubbing.md +43 -0
- package/skills/sentry/references/concepts/errors.md +40 -0
- package/skills/sentry/references/concepts/logging.md +85 -0
- package/skills/sentry/references/concepts/metrics.md +49 -0
- package/skills/sentry/references/concepts/monitors.md +78 -0
- package/skills/sentry/references/concepts/profiling.md +38 -0
- package/skills/sentry/references/concepts/reduce-volume.md +49 -0
- package/skills/sentry/references/concepts/releases.md +43 -0
- package/skills/sentry/references/concepts/session-replay.md +35 -0
- package/skills/sentry/references/concepts/tracing.md +54 -0
- package/skills/sentry/references/concepts/user-feedback.md +36 -0
- package/skills/sentry/references/debug-artifacts/android.md +68 -0
- package/skills/sentry/references/debug-artifacts/apple.md +96 -0
- package/skills/sentry/references/debug-artifacts/dotnet.md +70 -0
- package/skills/sentry/references/debug-artifacts/flutter.md +65 -0
- package/skills/sentry/references/debug-artifacts/index.md +75 -0
- package/skills/sentry/references/debug-artifacts/javascript.md +94 -0
- package/skills/sentry/references/debug-artifacts/matching.md +73 -0
- package/skills/sentry/references/debug-artifacts/react-native.md +75 -0
- package/skills/sentry/references/first-error-setup.md +25 -0
- package/skills/sentry/references/instrumentation.md +30 -0
- package/skills/sentry/references/issues.md +32 -0
- package/skills/sentry/references/new-project.md +17 -0
- package/skills/sentry/references/otel-exporter.md +30 -0
- package/skills/sentry/references/release-workflow.md +31 -0
- package/skills/sentry/references/releases/ci-pipeline.md +214 -0
- package/skills/sentry/references/releases/index.md +93 -0
- package/skills/sentry/references/releases/suspect-commits.md +155 -0
- package/skills/sentry/references/releases/tagging.md +131 -0
- package/skills/sentry/references/releases/troubleshooting.md +67 -0
- package/skills/sentry/references/sdks/android/crons.md +305 -0
- package/skills/sentry/references/sdks/android/error-monitoring.md +800 -0
- package/skills/sentry/references/sdks/android/index.md +748 -0
- package/skills/sentry/references/sdks/android/integrations.md +48 -0
- package/skills/sentry/references/sdks/android/logging.md +374 -0
- package/skills/sentry/references/sdks/android/metrics.md +288 -0
- package/skills/sentry/references/sdks/android/profiling.md +397 -0
- package/skills/sentry/references/sdks/android/session-replay.md +406 -0
- package/skills/sentry/references/sdks/android/tracing.md +861 -0
- package/skills/sentry/references/sdks/browser/error-monitoring.md +861 -0
- package/skills/sentry/references/sdks/browser/index.md +714 -0
- package/skills/sentry/references/sdks/browser/logging.md +315 -0
- package/skills/sentry/references/sdks/browser/profiling.md +236 -0
- package/skills/sentry/references/sdks/browser/session-replay.md +586 -0
- package/skills/sentry/references/sdks/browser/tracing.md +561 -0
- package/skills/sentry/references/sdks/browser/user-feedback.md +354 -0
- package/skills/sentry/references/sdks/cloudflare/ai-monitoring.md +661 -0
- package/skills/sentry/references/sdks/cloudflare/crons.md +231 -0
- package/skills/sentry/references/sdks/cloudflare/durable-objects.md +381 -0
- package/skills/sentry/references/sdks/cloudflare/error-monitoring.md +329 -0
- package/skills/sentry/references/sdks/cloudflare/index.md +698 -0
- package/skills/sentry/references/sdks/cloudflare/logging.md +169 -0
- package/skills/sentry/references/sdks/cloudflare/nodejs-compat.md +134 -0
- package/skills/sentry/references/sdks/cloudflare/tracing.md +475 -0
- package/skills/sentry/references/sdks/cocoa/error-monitoring.md +394 -0
- package/skills/sentry/references/sdks/cocoa/index.md +497 -0
- package/skills/sentry/references/sdks/cocoa/logging.md +209 -0
- package/skills/sentry/references/sdks/cocoa/metrics.md +136 -0
- package/skills/sentry/references/sdks/cocoa/profiling.md +223 -0
- package/skills/sentry/references/sdks/cocoa/session-replay.md +257 -0
- package/skills/sentry/references/sdks/cocoa/tracing.md +524 -0
- package/skills/sentry/references/sdks/cocoa/user-feedback.md +310 -0
- package/skills/sentry/references/sdks/dotnet/crons.md +465 -0
- package/skills/sentry/references/sdks/dotnet/error-monitoring.md +1100 -0
- package/skills/sentry/references/sdks/dotnet/index.md +614 -0
- package/skills/sentry/references/sdks/dotnet/logging.md +556 -0
- package/skills/sentry/references/sdks/dotnet/metrics.md +229 -0
- package/skills/sentry/references/sdks/dotnet/profiling.md +296 -0
- package/skills/sentry/references/sdks/dotnet/tracing.md +897 -0
- package/skills/sentry/references/sdks/elixir/crons.md +371 -0
- package/skills/sentry/references/sdks/elixir/error-monitoring.md +335 -0
- package/skills/sentry/references/sdks/elixir/index.md +383 -0
- package/skills/sentry/references/sdks/elixir/logging.md +239 -0
- package/skills/sentry/references/sdks/elixir/tracing.md +233 -0
- package/skills/sentry/references/sdks/flutter/ecosystem-integrations.md +70 -0
- package/skills/sentry/references/sdks/flutter/error-monitoring.md +312 -0
- package/skills/sentry/references/sdks/flutter/index.md +728 -0
- package/skills/sentry/references/sdks/flutter/logging.md +387 -0
- package/skills/sentry/references/sdks/flutter/metrics.md +310 -0
- package/skills/sentry/references/sdks/flutter/profiling.md +214 -0
- package/skills/sentry/references/sdks/flutter/session-replay.md +308 -0
- package/skills/sentry/references/sdks/flutter/tracing.md +502 -0
- package/skills/sentry/references/sdks/go/crons.md +270 -0
- package/skills/sentry/references/sdks/go/error-monitoring.md +361 -0
- package/skills/sentry/references/sdks/go/index.md +324 -0
- package/skills/sentry/references/sdks/go/logging.md +354 -0
- package/skills/sentry/references/sdks/go/metrics.md +273 -0
- package/skills/sentry/references/sdks/go/profiling.md +46 -0
- package/skills/sentry/references/sdks/go/tracing.md +366 -0
- package/skills/sentry/references/sdks/index.md +41 -0
- package/skills/sentry/references/sdks/nestjs/ai-monitoring.md +410 -0
- package/skills/sentry/references/sdks/nestjs/crons.md +268 -0
- package/skills/sentry/references/sdks/nestjs/error-monitoring.md +729 -0
- package/skills/sentry/references/sdks/nestjs/index.md +699 -0
- package/skills/sentry/references/sdks/nestjs/logging.md +174 -0
- package/skills/sentry/references/sdks/nestjs/metrics.md +243 -0
- package/skills/sentry/references/sdks/nestjs/profiling.md +127 -0
- package/skills/sentry/references/sdks/nestjs/tracing.md +762 -0
- package/skills/sentry/references/sdks/nextjs/ai-monitoring.md +494 -0
- package/skills/sentry/references/sdks/nextjs/crons.md +383 -0
- package/skills/sentry/references/sdks/nextjs/error-monitoring.md +974 -0
- package/skills/sentry/references/sdks/nextjs/index.md +491 -0
- package/skills/sentry/references/sdks/nextjs/logging.md +381 -0
- package/skills/sentry/references/sdks/nextjs/metrics.md +411 -0
- package/skills/sentry/references/sdks/nextjs/profiling.md +403 -0
- package/skills/sentry/references/sdks/nextjs/session-replay.md +462 -0
- package/skills/sentry/references/sdks/nextjs/tracing.md +628 -0
- package/skills/sentry/references/sdks/node/ai-monitoring.md +303 -0
- package/skills/sentry/references/sdks/node/crons.md +432 -0
- package/skills/sentry/references/sdks/node/error-monitoring.md +1125 -0
- package/skills/sentry/references/sdks/node/index.md +942 -0
- package/skills/sentry/references/sdks/node/logging.md +380 -0
- package/skills/sentry/references/sdks/node/metrics.md +278 -0
- package/skills/sentry/references/sdks/node/profiling.md +373 -0
- package/skills/sentry/references/sdks/node/tracing.md +878 -0
- package/skills/sentry/references/sdks/php/ai-monitoring.md +310 -0
- package/skills/sentry/references/sdks/php/crons.md +265 -0
- package/skills/sentry/references/sdks/php/error-monitoring.md +626 -0
- package/skills/sentry/references/sdks/php/index.md +362 -0
- package/skills/sentry/references/sdks/php/laravel.md +542 -0
- package/skills/sentry/references/sdks/php/logging.md +242 -0
- package/skills/sentry/references/sdks/php/metrics.md +193 -0
- package/skills/sentry/references/sdks/php/profiling.md +115 -0
- package/skills/sentry/references/sdks/php/symfony.md +552 -0
- package/skills/sentry/references/sdks/php/tracing.md +516 -0
- package/skills/sentry/references/sdks/python/ai-monitoring.md +351 -0
- package/skills/sentry/references/sdks/python/crons.md +218 -0
- package/skills/sentry/references/sdks/python/error-monitoring.md +292 -0
- package/skills/sentry/references/sdks/python/index.md +361 -0
- package/skills/sentry/references/sdks/python/logging.md +234 -0
- package/skills/sentry/references/sdks/python/metrics.md +154 -0
- package/skills/sentry/references/sdks/python/profiling.md +120 -0
- package/skills/sentry/references/sdks/python/tracing.md +364 -0
- package/skills/sentry/references/sdks/react/error-monitoring.md +1607 -0
- package/skills/sentry/references/sdks/react/index.md +492 -0
- package/skills/sentry/references/sdks/react/logging.md +364 -0
- package/skills/sentry/references/sdks/react/profiling.md +322 -0
- package/skills/sentry/references/sdks/react/react-features.md +1272 -0
- package/skills/sentry/references/sdks/react/session-replay.md +1193 -0
- package/skills/sentry/references/sdks/react/tracing.md +1415 -0
- package/skills/sentry/references/sdks/react-native/error-monitoring.md +1481 -0
- package/skills/sentry/references/sdks/react-native/expo-config-plugin.md +45 -0
- package/skills/sentry/references/sdks/react-native/index.md +1030 -0
- package/skills/sentry/references/sdks/react-native/logging.md +444 -0
- package/skills/sentry/references/sdks/react-native/profiling.md +386 -0
- package/skills/sentry/references/sdks/react-native/session-replay.md +704 -0
- package/skills/sentry/references/sdks/react-native/tracing.md +1086 -0
- package/skills/sentry/references/sdks/react-native/user-feedback.md +815 -0
- package/skills/sentry/references/sdks/react-router-framework/error-monitoring.md +127 -0
- package/skills/sentry/references/sdks/react-router-framework/index.md +411 -0
- package/skills/sentry/references/sdks/react-router-framework/logging.md +66 -0
- package/skills/sentry/references/sdks/react-router-framework/profiling.md +57 -0
- package/skills/sentry/references/sdks/react-router-framework/react-router-framework-features.md +110 -0
- package/skills/sentry/references/sdks/react-router-framework/session-replay.md +67 -0
- package/skills/sentry/references/sdks/react-router-framework/tracing.md +96 -0
- package/skills/sentry/references/sdks/react-router-framework/user-feedback.md +71 -0
- package/skills/sentry/references/sdks/ruby/crons.md +184 -0
- package/skills/sentry/references/sdks/ruby/error-monitoring.md +248 -0
- package/skills/sentry/references/sdks/ruby/index.md +297 -0
- package/skills/sentry/references/sdks/ruby/logging.md +168 -0
- package/skills/sentry/references/sdks/ruby/metrics.md +196 -0
- package/skills/sentry/references/sdks/ruby/migration.md +321 -0
- package/skills/sentry/references/sdks/ruby/profiling.md +107 -0
- package/skills/sentry/references/sdks/ruby/tracing.md +388 -0
- package/skills/sentry/references/sdks/svelte/error-monitoring.md +456 -0
- package/skills/sentry/references/sdks/svelte/index.md +467 -0
- package/skills/sentry/references/sdks/svelte/logging.md +344 -0
- package/skills/sentry/references/sdks/svelte/session-replay.md +369 -0
- package/skills/sentry/references/sdks/svelte/tracing.md +406 -0
- package/skills/sentry/references/sdks/tanstack-start/error-monitoring.md +149 -0
- package/skills/sentry/references/sdks/tanstack-start/index.md +381 -0
- package/skills/sentry/references/sdks/tanstack-start/logging.md +74 -0
- package/skills/sentry/references/sdks/tanstack-start/session-replay.md +76 -0
- package/skills/sentry/references/sdks/tanstack-start/tanstackstart-features.md +128 -0
- package/skills/sentry/references/sdks/tanstack-start/tracing.md +123 -0
- package/skills/sentry/references/sdks/tanstack-start/user-feedback.md +81 -0
- package/skills/sentry/references/search-query-language.md +226 -0
- package/skills/sentry/references/semantics/angular.md +7 -0
- package/skills/sentry/references/semantics/app.md +28 -0
- package/skills/sentry/references/semantics/art.md +17 -0
- package/skills/sentry/references/semantics/aws.md +43 -0
- package/skills/sentry/references/semantics/browser.md +34 -0
- package/skills/sentry/references/semantics/cache.md +12 -0
- package/skills/sentry/references/semantics/client.md +8 -0
- package/skills/sentry/references/semantics/cloud.md +12 -0
- package/skills/sentry/references/semantics/cloudflare.md +23 -0
- package/skills/sentry/references/semantics/code.md +11 -0
- package/skills/sentry/references/semantics/culture.md +11 -0
- package/skills/sentry/references/semantics/db.md +21 -0
- package/skills/sentry/references/semantics/device.md +43 -0
- package/skills/sentry/references/semantics/error.md +7 -0
- package/skills/sentry/references/semantics/event.md +8 -0
- package/skills/sentry/references/semantics/exception.md +10 -0
- package/skills/sentry/references/semantics/faas.md +19 -0
- package/skills/sentry/references/semantics/file.md +8 -0
- package/skills/sentry/references/semantics/flag.md +7 -0
- package/skills/sentry/references/semantics/gcp.md +16 -0
- package/skills/sentry/references/semantics/gen_ai.md +53 -0
- package/skills/sentry/references/semantics/general.md +11 -0
- package/skills/sentry/references/semantics/graphql.md +9 -0
- package/skills/sentry/references/semantics/grpc.md +19 -0
- package/skills/sentry/references/semantics/http.md +34 -0
- package/skills/sentry/references/semantics/index.md +63 -0
- package/skills/sentry/references/semantics/jsonrpc.md +8 -0
- package/skills/sentry/references/semantics/jvm.md +12 -0
- package/skills/sentry/references/semantics/koa.md +7 -0
- package/skills/sentry/references/semantics/logger.md +7 -0
- package/skills/sentry/references/semantics/mcp.md +37 -0
- package/skills/sentry/references/semantics/mdc.md +7 -0
- package/skills/sentry/references/semantics/messaging.md +23 -0
- package/skills/sentry/references/semantics/middleware.md +7 -0
- package/skills/sentry/references/semantics/navigation.md +9 -0
- package/skills/sentry/references/semantics/nel.md +11 -0
- package/skills/sentry/references/semantics/network.md +17 -0
- package/skills/sentry/references/semantics/os.md +15 -0
- package/skills/sentry/references/semantics/otel.md +10 -0
- package/skills/sentry/references/semantics/params.md +7 -0
- package/skills/sentry/references/semantics/process.md +14 -0
- package/skills/sentry/references/semantics/react.md +7 -0
- package/skills/sentry/references/semantics/remix.md +7 -0
- package/skills/sentry/references/semantics/resource.md +7 -0
- package/skills/sentry/references/semantics/rpc.md +10 -0
- package/skills/sentry/references/semantics/score.md +10 -0
- package/skills/sentry/references/semantics/sentry.md +69 -0
- package/skills/sentry/references/semantics/server.md +8 -0
- package/skills/sentry/references/semantics/service.md +8 -0
- package/skills/sentry/references/semantics/session.md +7 -0
- package/skills/sentry/references/semantics/state.md +7 -0
- package/skills/sentry/references/semantics/thread.md +8 -0
- package/skills/sentry/references/semantics/timber.md +7 -0
- package/skills/sentry/references/semantics/trpc.md +8 -0
- package/skills/sentry/references/semantics/ui.md +18 -0
- package/skills/sentry/references/semantics/url.md +15 -0
- package/skills/sentry/references/semantics/user.md +17 -0
- package/skills/sentry/references/semantics/user_agent.md +7 -0
- package/skills/sentry/references/semantics/vercel.md +42 -0
- package/skills/sentry/references/setup-verification.md +39 -0
- package/skills/sentry/references/snapshots/github-actions-fanout.md +206 -0
- package/skills/sentry/references/snapshots/github-actions-simple.md +102 -0
- package/skills/sentry/references/snapshots/github-actions-swift-snapshot-testing.md +118 -0
- package/skills/sentry/references/snapshots/index.md +19 -0
- package/skills/sentry/references/snapshots/snapshot-previews.md +100 -0
- package/skills/sentry/references/snapshots/snapshots.md +123 -0
- package/skills/sentry/references/snapshots/wizard-setup.md +134 -0
- package/skills/testing/LICENSE +21 -0
- package/skills/testing/NOTICE +7 -0
- package/skills/testing/SKILL.md +13 -19
- package/skills/testing/agents/openai.yaml +1 -2
- package/skills/testing/references/selection.md +23 -0
- package/skills/testing/references/tdd.md +19 -0
- package/skills/testing/references/test-design.md +17 -0
- package/src/catalog.ts +1 -7
- package/skills/build-effect-apis/SKILL.md +0 -81
- package/skills/build-effect-apis/agents/openai.yaml +0 -4
- package/skills/build-effect-clis/SKILL.md +0 -92
- package/skills/build-effect-clis/agents/openai.yaml +0 -4
- package/skills/effect-architecture-audit/agents/openai.yaml +0 -4
- package/skills/effect-atom-state/SKILL.md +0 -97
- package/skills/effect-atom-state/agents/openai.yaml +0 -4
- package/skills/effect-ts/SKILL.md +0 -35
- package/skills/effect-ts/agents/openai.yaml +0 -4
- /package/skills/{build-effect-apis/references → effect-development/references/api}/cloudflare-workers.md +0 -0
- /package/skills/{build-effect-apis/references → effect-development/references/api}/runtime-assembly.md +0 -0
- /package/skills/{build-effect-apis/references → effect-development/references/api}/server-and-middleware.md +0 -0
- /package/skills/{build-effect-apis/references → effect-development/references/api}/shared-contracts.md +0 -0
- /package/skills/{effect-architecture-audit/references → effect-development/references/architecture}/service-and-boundary-audit.md +0 -0
- /package/skills/{effect-atom-state/references → effect-development/references/atom}/effect-atom-lifecycle.md +0 -0
- /package/skills/{effect-atom-state/references → effect-development/references/atom}/effect-atom-workflows.md +0 -0
- /package/skills/{effect-atom-state/references → effect-development/references/atom}/tanstack-start.md +0 -0
- /package/skills/{build-effect-clis/references → effect-development/references/cli}/command-design.md +0 -0
- /package/skills/{build-effect-clis/references → effect-development/references/cli}/processes-and-platform.md +0 -0
|
@@ -0,0 +1,661 @@
|
|
|
1
|
+
# AI / LLM Monitoring (Agent Tracing) — Sentry Cloudflare SDK
|
|
2
|
+
|
|
3
|
+
> Minimum SDK: `@sentry/cloudflare` >=10.61.0 (Gen AI span streaming on by default).
|
|
4
|
+
> Workers AI (`env.AI`) auto-instrumentation: v10.67.0+. Vite plugin build-time
|
|
5
|
+
> instrumentation: v10.68.0+ (experimental).
|
|
6
|
+
> Docs:
|
|
7
|
+
> [docs.sentry.io/platforms/javascript/guides/cloudflare/agent-tracing/](https://docs.sentry.io/platforms/javascript/guides/cloudflare/agent-tracing/)
|
|
8
|
+
|
|
9
|
+
Sentry Agent Tracing captures `gen_ai` spans for LLM calls, agent runs, and tool
|
|
10
|
+
executions — token usage, latency, prompts/responses, and error rates — and groups
|
|
11
|
+
multi-turn chats in Conversations.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## The Cloudflare Difference
|
|
16
|
+
|
|
17
|
+
The Cloudflare Workers runtime (`workerd`) does **not support runtime monkey-patching**,
|
|
18
|
+
so the automatic AI instrumentation that Node.js gets for free does not happen here.
|
|
19
|
+
On Cloudflare there are three ways to get `gen_ai` spans, in order of preference:
|
|
20
|
+
|
|
21
|
+
| Path | Covers | How it works |
|
|
22
|
+
| --------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
|
|
23
|
+
| **1. Workers AI binding** (automatic) | `env.AI.run(...)` | `withSentry` wraps `env` — nothing to do (v10.67.0+) |
|
|
24
|
+
| **2. Vite plugin** (build-time, experimental) | `openai`, `@anthropic-ai/sdk`, `@google/genai`, `ai` (Vercel AI SDK) | `sentryCloudflareVitePlugin` injects `diagnostics_channel` calls into the bundled packages at build time (v10.68.0+) |
|
|
25
|
+
| **3. Manual client wrapping** | OpenAI, Anthropic, Google Gen AI, LangChain, LangGraph | Wrap each client/graph with the matching `Sentry.instrument*` helper |
|
|
26
|
+
|
|
27
|
+
LangChain and LangGraph are **not** covered by the Vite plugin’s channel injection —
|
|
28
|
+
they always require the manual helpers (path 3).
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Prerequisites
|
|
33
|
+
|
|
34
|
+
Tracing must be enabled — AI spans require an active trace.
|
|
35
|
+
Pass `dataCollection` so generative AI content (prompts and responses) is collected
|
|
36
|
+
according to SDK defaults:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import * as Sentry from "@sentry/cloudflare";
|
|
40
|
+
|
|
41
|
+
export default Sentry.withSentry(
|
|
42
|
+
(env: Env) => ({
|
|
43
|
+
dsn: env.SENTRY_DSN,
|
|
44
|
+
tracesSampleRate: 1.0,
|
|
45
|
+
dataCollection: {
|
|
46
|
+
// To disable sending user data and HTTP bodies, uncomment the lines below. For more info visit:
|
|
47
|
+
// https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/options/#dataCollection
|
|
48
|
+
// userInfo: false,
|
|
49
|
+
// httpBodies: [],
|
|
50
|
+
},
|
|
51
|
+
}),
|
|
52
|
+
handler,
|
|
53
|
+
);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**PII warning:** with `dataCollection` set (even `{}`), genAI input/output capture is
|
|
57
|
+
**on by default** — prompts and model responses are sent to Sentry.
|
|
58
|
+
To turn it off:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
dataCollection: {
|
|
62
|
+
genAI: { inputs: false, outputs: false },
|
|
63
|
+
},
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Per-integration `recordInputs` / `recordOutputs` options override the global default.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Integration Matrix
|
|
71
|
+
|
|
72
|
+
| AI stack | Supported versions | Instrumentation | Min SDK |
|
|
73
|
+
| ------------------------------------------- | ------------------ | ------------------------------------------------ | ------------------------------------------------------ |
|
|
74
|
+
| Workers AI (`env.AI`) | — | Automatic via `withSentry` | 10.67.0 |
|
|
75
|
+
| OpenAI (`openai`) | `>=4.0.0 <7` | Vite plugin **or** `instrumentOpenAiClient` | 10.68.0 / — |
|
|
76
|
+
| Anthropic (`@anthropic-ai/sdk`) | `>=0.19.2 <1.0.0` | Vite plugin **or** `instrumentAnthropicAiClient` | 10.68.0 / — |
|
|
77
|
+
| Google Gen AI (`@google/genai`) | `>=0.10.0 <2` | Vite plugin **or** `instrumentGoogleGenAIClient` | 10.68.0 / — |
|
|
78
|
+
| Vercel AI SDK (`ai`) | `>=3.0.0 <=7` | `vercelAIIntegration` (+ Vite plugin injection) | 10.6.0; v7 needs 10.64.0 + `/nodejs_compat` entrypoint |
|
|
79
|
+
| LangChain (`langchain`) | `>=0.1.0 <2.0.0` | `createLangChainCallbackHandler` (manual only) | — |
|
|
80
|
+
| LangGraph (`@langchain/langgraph`) | `>=0.2.0 <2.0.0` | `instrumentLangGraph` (manual only) | — |
|
|
81
|
+
| Other providers (Bedrock, Mistral, Groq, …) | — | Manual `gen_ai.*` spans | — |
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Path 1: Workers AI (Automatic)
|
|
86
|
+
|
|
87
|
+
The Workers AI binding is auto-instrumented by `withSentry` (v10.67.0+). Calls to
|
|
88
|
+
`env.AI.run(...)` create `gen_ai` spans capturing model, request parameters, and token
|
|
89
|
+
usage — as long as your handler uses the `env` the SDK passes in:
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import * as Sentry from "@sentry/cloudflare";
|
|
93
|
+
|
|
94
|
+
export default Sentry.withSentry(
|
|
95
|
+
(env: Env) => ({
|
|
96
|
+
dsn: env.SENTRY_DSN,
|
|
97
|
+
tracesSampleRate: 1.0,
|
|
98
|
+
}),
|
|
99
|
+
{
|
|
100
|
+
async fetch(request, env, ctx) {
|
|
101
|
+
// env.AI is automatically instrumented
|
|
102
|
+
const result = await env.AI.run("@cf/meta/llama-3.1-8b-instruct", {
|
|
103
|
+
messages: [{ role: "user", content: "What is the capital of France?" }],
|
|
104
|
+
});
|
|
105
|
+
return new Response(JSON.stringify(result));
|
|
106
|
+
},
|
|
107
|
+
} satisfies ExportedHandler<Env>,
|
|
108
|
+
);
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Auto-instrumentation covers the spans — not the grouping.** Workers AI does **not**
|
|
112
|
+
infer a conversation ID, so without one every `env.AI.run(...)` call lands as an
|
|
113
|
+
isolated span and the Conversations view stays empty.
|
|
114
|
+
For any chat-style app, set a conversation ID as part of this setup — don’t treat it as
|
|
115
|
+
a later add-on:
|
|
116
|
+
|
|
117
|
+
1. Generate a stable session ID on the client (e.g. `crypto.randomUUID()` once per chat
|
|
118
|
+
session) and send it with every AI request
|
|
119
|
+
2. In the handler, call `Sentry.setConversationId(id)` **before** any `env.AI.run(...)`
|
|
120
|
+
calls
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
async fetch(request, env, ctx) {
|
|
124
|
+
const { conversationId, messages } = await request.json();
|
|
125
|
+
|
|
126
|
+
// Before any AI calls — groups this request's gen_ai spans into a Conversation
|
|
127
|
+
Sentry.setConversationId(conversationId);
|
|
128
|
+
|
|
129
|
+
const result = await env.AI.run("@cf/meta/llama-3.1-8b-instruct", { messages });
|
|
130
|
+
return new Response(JSON.stringify(result));
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
See [Tracking Conversations](#tracking-conversations) for scope semantics, user
|
|
135
|
+
attribution, and the Agents SDK pattern.
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Path 2: Vite Plugin (Build-Time Instrumentation)
|
|
140
|
+
|
|
141
|
+
> **Experimental** (v10.68.0+): options and behavior may change or be removed in any
|
|
142
|
+
> release. Verify against the
|
|
143
|
+
> [Vite plugin docs](https://docs.sentry.io/platforms/javascript/guides/cloudflare/features/vite-plugin/)
|
|
144
|
+
> before implementing.
|
|
145
|
+
|
|
146
|
+
`sentryCloudflareVitePlugin` ships with `@sentry/cloudflare` (no extra package) via the
|
|
147
|
+
`@sentry/cloudflare/vite` export.
|
|
148
|
+
It is designed to run alongside the
|
|
149
|
+
[Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/). With
|
|
150
|
+
`useDiagnosticsChannelInjection` enabled, it injects
|
|
151
|
+
`diagnostics_channel.tracingChannel` calls into supported bundled packages — including
|
|
152
|
+
`openai`, `@anthropic-ai/sdk`, `@google/genai`, and `ai` — so the SDK traces them
|
|
153
|
+
without monkey-patching.
|
|
154
|
+
The matching Sentry integrations are registered automatically; you don’t wrap clients or
|
|
155
|
+
add integrations manually.
|
|
156
|
+
|
|
157
|
+
**Prerequisite:** the injected code uses Node.js `diagnostics_channel` at runtime, so
|
|
158
|
+
the Worker must have the `nodejs_compat` compatibility flag (see `./nodejs-compat.md`).
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
// vite.config.ts
|
|
162
|
+
import { cloudflare } from "@cloudflare/vite-plugin";
|
|
163
|
+
import { sentryCloudflareVitePlugin } from "@sentry/cloudflare/vite";
|
|
164
|
+
import { defineConfig } from "vite";
|
|
165
|
+
|
|
166
|
+
export default defineConfig({
|
|
167
|
+
plugins: [
|
|
168
|
+
cloudflare(),
|
|
169
|
+
sentryCloudflareVitePlugin({
|
|
170
|
+
_experimental: {
|
|
171
|
+
useDiagnosticsChannelInjection: true,
|
|
172
|
+
},
|
|
173
|
+
}),
|
|
174
|
+
],
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Keep `withSentry` in your Worker entry as usual:
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
import * as Sentry from "@sentry/cloudflare/nodejs_compat";
|
|
182
|
+
import OpenAI from "openai";
|
|
183
|
+
|
|
184
|
+
export default Sentry.withSentry(
|
|
185
|
+
(env: Env) => ({
|
|
186
|
+
dsn: env.SENTRY_DSN,
|
|
187
|
+
tracesSampleRate: 1.0,
|
|
188
|
+
}),
|
|
189
|
+
{
|
|
190
|
+
async fetch(request, env, ctx) {
|
|
191
|
+
const openai = new OpenAI({ apiKey: env.OPENAI_API_KEY });
|
|
192
|
+
// Traced automatically — the Vite plugin injected channels at build time
|
|
193
|
+
const response = await openai.chat.completions.create({
|
|
194
|
+
model: "gpt-4o",
|
|
195
|
+
messages: [{ role: "user", content: "Hello" }],
|
|
196
|
+
});
|
|
197
|
+
return new Response(response.choices[0].message.content);
|
|
198
|
+
},
|
|
199
|
+
} satisfies ExportedHandler<Env>,
|
|
200
|
+
);
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Both `vite build` and `vite dev` are instrumented.
|
|
204
|
+
When the option is disabled or omitted, the plugin is a no-op.
|
|
205
|
+
|
|
206
|
+
### Auto-Instrumentation (Experimental)
|
|
207
|
+
|
|
208
|
+
The plugin can also wrap your Worker at build time so you don’t need `withSentry` in
|
|
209
|
+
your code. With `autoInstrumentation` enabled, it reads your Wrangler config (probing
|
|
210
|
+
`wrangler.json`, `wrangler.jsonc`, `wrangler.toml` at the Vite root — set the top-level
|
|
211
|
+
`wranglerConfigPath` option for a custom name, v10.69.0+), wraps the default export with
|
|
212
|
+
`Sentry.withSentry()`, and wraps configured classes with the matching helper: Durable
|
|
213
|
+
Objects with `instrumentDurableObjectWithSentry`, Workflows with
|
|
214
|
+
`instrumentWorkflowWithSentry`, and — since v10.69.0 — Cloudflare Agents SDK classes
|
|
215
|
+
(`Agent`, `AIChatAgent`, `McpAgent`) with `instrumentAgentWithSentry`, which also gives
|
|
216
|
+
them automatic conversation IDs (see [Tracking Conversations](#tracking-conversations)):
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
// vite.config.ts
|
|
220
|
+
sentryCloudflareVitePlugin({
|
|
221
|
+
_experimental: {
|
|
222
|
+
autoInstrumentation: true,
|
|
223
|
+
useDiagnosticsChannelInjection: true,
|
|
224
|
+
},
|
|
225
|
+
}),
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Provide Sentry options via a co-located `instrument.server.*` file (`.ts`, `.mts`,
|
|
229
|
+
`.js`, `.mjs`, or `.cjs`) next to your Worker entry — use `defineCloudflareOptions` for
|
|
230
|
+
type-checking:
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
// instrument.server.ts
|
|
234
|
+
import { defineCloudflareOptions } from "@sentry/cloudflare";
|
|
235
|
+
|
|
236
|
+
export default defineCloudflareOptions((env) => ({
|
|
237
|
+
dsn: env.SENTRY_DSN,
|
|
238
|
+
tracesSampleRate: 1.0,
|
|
239
|
+
}));
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
If no `instrument.server.*` file exists, the SDK reads configuration (DSN, release,
|
|
243
|
+
environment, sample rate) from the Worker’s `env` bindings at runtime.
|
|
244
|
+
|
|
245
|
+
### Migrating From Wrangler
|
|
246
|
+
|
|
247
|
+
If you deploy with `wrangler` directly today:
|
|
248
|
+
|
|
249
|
+
1. Set up the
|
|
250
|
+
[Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/get-started/)
|
|
251
|
+
and add a `vite.config.ts` with `cloudflare()` and `sentryCloudflareVitePlugin()` as
|
|
252
|
+
above.
|
|
253
|
+
2. Run `vite build` before `wrangler deploy`, and use `vite dev` instead of
|
|
254
|
+
`wrangler dev` for local development.
|
|
255
|
+
|
|
256
|
+
Your existing `wrangler.jsonc`/`wrangler.toml` stays the input config — the plugin
|
|
257
|
+
generates the deployed output during the build.
|
|
258
|
+
Everything works without Vite too; you just miss the build-time instrumentation of
|
|
259
|
+
bundled dependencies.
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## Path 3: Manual Client Wrapping
|
|
264
|
+
|
|
265
|
+
Use these when you don’t build with Vite, or for LangChain/LangGraph (which the Vite
|
|
266
|
+
plugin doesn’t cover).
|
|
267
|
+
All wrappers default `recordInputs`/`recordOutputs` to `true` when
|
|
268
|
+
`dataCollection.genAI` inputs/outputs are on (the default).
|
|
269
|
+
|
|
270
|
+
### OpenAI
|
|
271
|
+
|
|
272
|
+
```typescript
|
|
273
|
+
import OpenAI from "openai";
|
|
274
|
+
import * as Sentry from "@sentry/cloudflare";
|
|
275
|
+
|
|
276
|
+
const openai = new OpenAI({ apiKey: env.OPENAI_API_KEY });
|
|
277
|
+
const client = Sentry.instrumentOpenAiClient(openai, {
|
|
278
|
+
recordInputs: true,
|
|
279
|
+
recordOutputs: true,
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
// Use the wrapped client instead of the original instance
|
|
283
|
+
const response = await client.chat.completions.create({
|
|
284
|
+
model: "gpt-4o",
|
|
285
|
+
messages: [{ role: "user", content: "Hello" }],
|
|
286
|
+
});
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Traces `chat.completions.create()` and `responses.create()`.
|
|
290
|
+
|
|
291
|
+
### Anthropic
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
295
|
+
import * as Sentry from "@sentry/cloudflare";
|
|
296
|
+
|
|
297
|
+
const anthropic = new Anthropic({ apiKey: env.ANTHROPIC_API_KEY });
|
|
298
|
+
const client = Sentry.instrumentAnthropicAiClient(anthropic, {
|
|
299
|
+
recordInputs: true,
|
|
300
|
+
recordOutputs: true,
|
|
301
|
+
});
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Google Gen AI
|
|
305
|
+
|
|
306
|
+
```typescript
|
|
307
|
+
import { GoogleGenAI } from "@google/genai";
|
|
308
|
+
import * as Sentry from "@sentry/cloudflare";
|
|
309
|
+
|
|
310
|
+
const genAI = new GoogleGenAI({ apiKey: env.GOOGLE_API_KEY });
|
|
311
|
+
const client = Sentry.instrumentGoogleGenAIClient(genAI, {
|
|
312
|
+
recordInputs: true,
|
|
313
|
+
recordOutputs: true,
|
|
314
|
+
});
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Vercel AI SDK
|
|
318
|
+
|
|
319
|
+
The `vercelAIIntegration` is **not enabled by default** — add it to `Sentry.init`
|
|
320
|
+
options, and pass `experimental_telemetry: { isEnabled: true }` to every `generateText`
|
|
321
|
+
/ `generateObject` / `streamText` / `ToolLoopAgent` call:
|
|
322
|
+
|
|
323
|
+
```typescript
|
|
324
|
+
import * as Sentry from "@sentry/cloudflare";
|
|
325
|
+
import { generateText } from "ai";
|
|
326
|
+
|
|
327
|
+
export default Sentry.withSentry(
|
|
328
|
+
(env: Env) => ({
|
|
329
|
+
dsn: env.SENTRY_DSN,
|
|
330
|
+
tracesSampleRate: 1.0,
|
|
331
|
+
integrations: [Sentry.vercelAIIntegration()],
|
|
332
|
+
}),
|
|
333
|
+
{
|
|
334
|
+
async fetch(request, env, ctx) {
|
|
335
|
+
const result = await generateText({
|
|
336
|
+
model: openai("gpt-4o"),
|
|
337
|
+
prompt: "Hello",
|
|
338
|
+
experimental_telemetry: {
|
|
339
|
+
isEnabled: true,
|
|
340
|
+
recordInputs: true,
|
|
341
|
+
recordOutputs: true,
|
|
342
|
+
},
|
|
343
|
+
});
|
|
344
|
+
return new Response(result.text);
|
|
345
|
+
},
|
|
346
|
+
} satisfies ExportedHandler<Env>,
|
|
347
|
+
);
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
**Version constraints:**
|
|
351
|
+
|
|
352
|
+
- AI SDK v3–v6: works on the default `@sentry/cloudflare` entrypoint (SDK >=10.6.0)
|
|
353
|
+
- AI SDK **v7**: requires SDK >=10.64.0 and the `@sentry/cloudflare/nodejs_compat`
|
|
354
|
+
entrypoint (see `./nodejs-compat.md`). Setting `recordInputs`/`recordOutputs` on the
|
|
355
|
+
integration itself is also only supported there — on the default entrypoint, set them
|
|
356
|
+
per call via `experimental_telemetry`
|
|
357
|
+
- Don’t use the AI SDK’s own `registerTelemetry` API (v7+) together with this
|
|
358
|
+
integration — it duplicates spans
|
|
359
|
+
|
|
360
|
+
### LangChain
|
|
361
|
+
|
|
362
|
+
Create a callback handler and pass it to LangChain operations (`invoke`, `stream`,
|
|
363
|
+
`batch`):
|
|
364
|
+
|
|
365
|
+
```typescript
|
|
366
|
+
import { ChatAnthropic } from "@langchain/anthropic";
|
|
367
|
+
import * as Sentry from "@sentry/cloudflare";
|
|
368
|
+
|
|
369
|
+
const callbackHandler = Sentry.createLangChainCallbackHandler({
|
|
370
|
+
recordInputs: true,
|
|
371
|
+
recordOutputs: true,
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
const model = new ChatAnthropic({
|
|
375
|
+
model: "claude-3-5-sonnet-20241022",
|
|
376
|
+
apiKey: env.ANTHROPIC_API_KEY,
|
|
377
|
+
});
|
|
378
|
+
await model.invoke("Tell me a joke", { callbacks: [callbackHandler] });
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
Captures chat model invocations, LLM pipelines, chain executions, and tool calls.
|
|
382
|
+
Supported provider packages: `@langchain/anthropic`, `@langchain/openai`,
|
|
383
|
+
`@langchain/google-genai`, `@langchain/mistralai`, `@langchain/google-vertexai`,
|
|
384
|
+
`@langchain/groq`.
|
|
385
|
+
|
|
386
|
+
### LangGraph
|
|
387
|
+
|
|
388
|
+
Instrument the `StateGraph` **before** calling `.compile()`:
|
|
389
|
+
|
|
390
|
+
```typescript
|
|
391
|
+
import { StateGraph, MessagesAnnotation, START, END } from "@langchain/langgraph";
|
|
392
|
+
import * as Sentry from "@sentry/cloudflare";
|
|
393
|
+
|
|
394
|
+
const agent = new StateGraph(MessagesAnnotation)
|
|
395
|
+
.addNode("agent", callLLM)
|
|
396
|
+
.addEdge(START, "agent")
|
|
397
|
+
.addEdge("agent", END);
|
|
398
|
+
|
|
399
|
+
Sentry.instrumentLangGraph(agent, {
|
|
400
|
+
recordInputs: true,
|
|
401
|
+
recordOutputs: true,
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
const graph = agent.compile({ name: "my_agent" });
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
Captures `gen_ai.create_agent` (compile) and `gen_ai.invoke_agent` (invoke) spans.
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
|
|
411
|
+
## Tracking Conversations
|
|
412
|
+
|
|
413
|
+
> **Beta:** configuration options and behavior may change.
|
|
414
|
+
|
|
415
|
+
Conversations groups multi-turn AI activity into a single replay of messages and tool
|
|
416
|
+
calls at **Explore > Conversations**. Every AI span in a chat session must share the
|
|
417
|
+
same `gen_ai.conversation.id`.
|
|
418
|
+
|
|
419
|
+
Some integrations infer the ID automatically.
|
|
420
|
+
For everything else — **including Workers AI** — set it yourself at the start of every
|
|
421
|
+
request or operation that makes AI calls, before those calls run.
|
|
422
|
+
Reuse the same session ID across messages in the chat; the ID applies to AI spans on the
|
|
423
|
+
current isolation scope (request-scoped).
|
|
424
|
+
Pass `null` to unset:
|
|
425
|
+
|
|
426
|
+
```typescript
|
|
427
|
+
Sentry.setConversationId("conv_abc123");
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
**Choose a real chat session ID** — a UUID or `conv_...` value your app creates when the
|
|
431
|
+
user starts a chat. Don’t use a user ID, room name, or a shared identifier: those group
|
|
432
|
+
unrelated chats into one conversation.
|
|
433
|
+
|
|
434
|
+
#### Cloudflare Agents SDK: automatic conversation IDs (v10.69.0+)
|
|
435
|
+
|
|
436
|
+
Wrap Agents SDK classes (`Agent`, `AIChatAgent`, `McpAgent`) with
|
|
437
|
+
`instrumentAgentWithSentry` and the conversation ID is set for you — on every chat turn
|
|
438
|
+
(`onChatMessage`) and every `@callable()` RPC call, defaulting to the agent instance
|
|
439
|
+
name. When the chat is cleared — `clearHistory()` from `useAgentChat`, or anything that
|
|
440
|
+
emits the
|
|
441
|
+
[`message:clear` observability event](https://developers.cloudflare.com/agents/runtime/operations/observability/#channels)
|
|
442
|
+
— the SDK rotates to a fresh conversation ID, so a reset chat groups as a new
|
|
443
|
+
conversation.
|
|
444
|
+
The Vite plugin’s `autoInstrumentation` applies this wrapper automatically.
|
|
445
|
+
See `./durable-objects.md` for the full API.
|
|
446
|
+
|
|
447
|
+
The conversation ID is the agent instance name, which is correct when one instance is
|
|
448
|
+
one chat session (e.g. `useAgent({ name: chatSessionId })`). If your instances are
|
|
449
|
+
per-user or a shared singleton like `"default"`, override it with your own session ID
|
|
450
|
+
via `Sentry.setConversationId(id)` at the start of `onChatMessage`, before any model or
|
|
451
|
+
tool calls.
|
|
452
|
+
|
|
453
|
+
On SDK versions before 10.69.0 (or with `instrumentDurableObjectWithSentry`), set the ID
|
|
454
|
+
manually — see `./tracing.md` for a full `AIChatAgent` example.
|
|
455
|
+
|
|
456
|
+
### Identifying Users
|
|
457
|
+
|
|
458
|
+
To populate the **User** column in Conversations, call `setUser` once per request or
|
|
459
|
+
session, before any AI calls:
|
|
460
|
+
|
|
461
|
+
```typescript
|
|
462
|
+
Sentry.setUser({ id: "user_123", email: "jane@example.com", username: "jane" });
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
Any of `id`, `email`, or `username` is sufficient.
|
|
466
|
+
|
|
467
|
+
### Streaming Gen AI Spans
|
|
468
|
+
|
|
469
|
+
Since SDK 10.61.0, `gen_ai` spans are sent as standalone envelope items instead of being
|
|
470
|
+
bundled into the transaction (`streamGenAiSpans` defaults to `true`). This prevents AI
|
|
471
|
+
spans with large inputs/outputs from hitting transaction payload limits, and is
|
|
472
|
+
**required** for Conversations to work.
|
|
473
|
+
**Self-hosted Sentry** users should set `streamGenAiSpans: false` — standalone `gen_ai`
|
|
474
|
+
spans may not be ingested by a self-hosted instance.
|
|
475
|
+
|
|
476
|
+
---
|
|
477
|
+
|
|
478
|
+
## Manual `gen_ai.*` Spans
|
|
479
|
+
|
|
480
|
+
For unsupported providers (Bedrock, Mistral, Groq, Cohere, …) or custom agent logic,
|
|
481
|
+
create spans yourself.
|
|
482
|
+
Spans nest like this:
|
|
483
|
+
|
|
484
|
+
```
|
|
485
|
+
invoke_agent My Agent (gen_ai.invoke_agent)
|
|
486
|
+
├── chat gpt-4o (gen_ai.chat) ← 1st LLM call
|
|
487
|
+
├── execute_tool get_weather (gen_ai.execute_tool) ← tool run
|
|
488
|
+
└── chat gpt-4o (gen_ai.chat) ← 2nd LLM call
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
Naming rules: span `op` MUST be `gen_ai.{operation.name}`; span `name` SHOULD be
|
|
492
|
+
`"{operation.name} {model-or-agent-or-tool}"`. Attributes only accept primitives —
|
|
493
|
+
JSON-stringify arrays/objects.
|
|
494
|
+
Messages use the `{role, parts}` format:
|
|
495
|
+
`[{"role": "user", "parts": [{"type": "text", "content": "..."}]}]`.
|
|
496
|
+
|
|
497
|
+
### AI request (`gen_ai.chat`)
|
|
498
|
+
|
|
499
|
+
```typescript
|
|
500
|
+
const messages = [{ role: "user", parts: [{ type: "text", content: "Tell me a joke" }] }];
|
|
501
|
+
|
|
502
|
+
await Sentry.startSpan(
|
|
503
|
+
{
|
|
504
|
+
op: "gen_ai.chat",
|
|
505
|
+
name: "chat o3-mini",
|
|
506
|
+
attributes: {
|
|
507
|
+
"gen_ai.operation.name": "chat",
|
|
508
|
+
"gen_ai.request.model": "o3-mini",
|
|
509
|
+
"gen_ai.provider.name": "openai",
|
|
510
|
+
"gen_ai.input.messages": JSON.stringify(messages),
|
|
511
|
+
},
|
|
512
|
+
},
|
|
513
|
+
async (span) => {
|
|
514
|
+
const result = await client.chat.completions.create({ model: "o3-mini", messages });
|
|
515
|
+
span.setAttribute("gen_ai.response.model", result.model);
|
|
516
|
+
span.setAttribute(
|
|
517
|
+
"gen_ai.output.messages",
|
|
518
|
+
JSON.stringify([
|
|
519
|
+
{
|
|
520
|
+
role: "assistant",
|
|
521
|
+
parts: [{ type: "text", content: result.choices[0].message.content }],
|
|
522
|
+
},
|
|
523
|
+
]),
|
|
524
|
+
);
|
|
525
|
+
span.setAttribute("gen_ai.usage.input_tokens", result.usage.prompt_tokens);
|
|
526
|
+
span.setAttribute("gen_ai.usage.output_tokens", result.usage.completion_tokens);
|
|
527
|
+
return result;
|
|
528
|
+
},
|
|
529
|
+
);
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
`gen_ai.operation.name` MUST be `"chat"`, `"embeddings"`, `"generate_content"`, or
|
|
533
|
+
`"text_completion"`.
|
|
534
|
+
|
|
535
|
+
### Agent lifecycle (`gen_ai.invoke_agent`)
|
|
536
|
+
|
|
537
|
+
```typescript
|
|
538
|
+
await Sentry.startSpan(
|
|
539
|
+
{
|
|
540
|
+
op: "gen_ai.invoke_agent",
|
|
541
|
+
name: "invoke_agent Weather Agent",
|
|
542
|
+
attributes: {
|
|
543
|
+
"gen_ai.operation.name": "invoke_agent",
|
|
544
|
+
"gen_ai.agent.name": "Weather Agent",
|
|
545
|
+
"gen_ai.request.model": "o3-mini",
|
|
546
|
+
},
|
|
547
|
+
},
|
|
548
|
+
async (span) => {
|
|
549
|
+
const result = await myAgent.run();
|
|
550
|
+
span.setAttribute("gen_ai.usage.input_tokens", result.usage.inputTokens);
|
|
551
|
+
span.setAttribute("gen_ai.usage.output_tokens", result.usage.outputTokens);
|
|
552
|
+
return result;
|
|
553
|
+
},
|
|
554
|
+
);
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
### Tool call (`gen_ai.execute_tool`)
|
|
558
|
+
|
|
559
|
+
```typescript
|
|
560
|
+
await Sentry.startSpan(
|
|
561
|
+
{
|
|
562
|
+
op: "gen_ai.execute_tool",
|
|
563
|
+
name: "execute_tool get_weather",
|
|
564
|
+
attributes: {
|
|
565
|
+
"gen_ai.operation.name": "execute_tool",
|
|
566
|
+
"gen_ai.tool.name": "get_weather",
|
|
567
|
+
"gen_ai.tool.type": "function",
|
|
568
|
+
"gen_ai.tool.call.arguments": JSON.stringify({ location: "Paris" }),
|
|
569
|
+
},
|
|
570
|
+
},
|
|
571
|
+
async (span) => {
|
|
572
|
+
const result = await getWeather({ location: "Paris" });
|
|
573
|
+
span.setAttribute("gen_ai.tool.call.result", JSON.stringify(result));
|
|
574
|
+
return result;
|
|
575
|
+
},
|
|
576
|
+
);
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
### Streaming responses
|
|
580
|
+
|
|
581
|
+
When the LLM streams, the span must outlive the initial callback — use
|
|
582
|
+
`Sentry.startInactiveSpan`, propagate with `Sentry.withActiveSpan`, and call
|
|
583
|
+
`span.end()` when the stream completes or errors.
|
|
584
|
+
Set `gen_ai.response.streaming: true` and the token counts after the stream finishes.
|
|
585
|
+
|
|
586
|
+
### Key attributes
|
|
587
|
+
|
|
588
|
+
| Attribute | Type | Notes |
|
|
589
|
+
| -------------------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------- |
|
|
590
|
+
| `gen_ai.request.model` | string | Requested model (required for chat spans) |
|
|
591
|
+
| `gen_ai.response.model` | string | Concrete model that responded |
|
|
592
|
+
| `gen_ai.provider.name` | string | e.g. `"openai"` |
|
|
593
|
+
| `gen_ai.agent.name` | string | Agent name (agent spans) |
|
|
594
|
+
| `gen_ai.input.messages` | string | JSON-stringified `{role, parts}` messages (replaces deprecated `gen_ai.request.messages`) |
|
|
595
|
+
| `gen_ai.output.messages` | string | JSON-stringified response messages (replaces deprecated `gen_ai.response.text` / `gen_ai.response.tool_calls`) |
|
|
596
|
+
| `gen_ai.tool.definitions` | string | JSON-stringified tool list (replaces deprecated `gen_ai.request.available_tools`) |
|
|
597
|
+
| `gen_ai.tool.call.arguments` / `gen_ai.tool.call.result` | string | Tool I/O (replace deprecated `gen_ai.tool.input` / `gen_ai.tool.output`) |
|
|
598
|
+
| `gen_ai.usage.input_tokens` | int | **Total** input tokens, including cached |
|
|
599
|
+
| `gen_ai.usage.input_tokens.cached` | int | Subset of input tokens served from cache |
|
|
600
|
+
| `gen_ai.usage.output_tokens` | int | **Total** output tokens, including reasoning |
|
|
601
|
+
| `gen_ai.usage.output_tokens.reasoning` | int | Subset used for reasoning |
|
|
602
|
+
|
|
603
|
+
> Cached and reasoning tokens are **subsets** of the totals, not additive.
|
|
604
|
+
> Sentry subtracts them from the totals to compute costs — reporting only the non-cached
|
|
605
|
+
> count as `input_tokens` produces wrong or negative cost calculations.
|
|
606
|
+
|
|
607
|
+
---
|
|
608
|
+
|
|
609
|
+
## Sampling
|
|
610
|
+
|
|
611
|
+
If `tracesSampleRate < 1.0`, AI calls that fall outside sampled traces produce no spans.
|
|
612
|
+
Use a `tracesSampler` that keeps AI-related traffic at 100% while sampling the rest
|
|
613
|
+
lower.
|
|
614
|
+
|
|
615
|
+
---
|
|
616
|
+
|
|
617
|
+
## Verification
|
|
618
|
+
|
|
619
|
+
Deploy (or `vite dev` / `wrangler dev` with a real DSN), trigger a route that makes an
|
|
620
|
+
AI call, then check:
|
|
621
|
+
|
|
622
|
+
1. **Insights > Agents** in Sentry — the AI Agents dashboard shows the model, token
|
|
623
|
+
usage, and latency
|
|
624
|
+
2. The trace view shows `gen_ai.*` spans nested under the request transaction
|
|
625
|
+
3. If you set `Sentry.setConversationId(...)`, the calls appear grouped in **Explore >
|
|
626
|
+
Conversations**
|
|
627
|
+
|
|
628
|
+
Minimal test handler (Workers AI — zero config beyond `withSentry`):
|
|
629
|
+
|
|
630
|
+
```typescript
|
|
631
|
+
async fetch(request, env, ctx) {
|
|
632
|
+
Sentry.setConversationId("test-conversation");
|
|
633
|
+
const result = await env.AI.run("@cf/meta/llama-3.1-8b-instruct", {
|
|
634
|
+
messages: [{ role: "user", content: "Say hello" }],
|
|
635
|
+
});
|
|
636
|
+
return new Response(JSON.stringify(result));
|
|
637
|
+
}
|
|
638
|
+
```
|
|
639
|
+
|
|
640
|
+
---
|
|
641
|
+
|
|
642
|
+
## Troubleshooting
|
|
643
|
+
|
|
644
|
+
| Issue | Cause | Solution |
|
|
645
|
+
| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
|
646
|
+
| No `gen_ai` spans at all | Tracing not enabled | Set `tracesSampleRate > 0`; verify the handler is wrapped with `withSentry` |
|
|
647
|
+
| OpenAI/Anthropic/Google calls not traced | No runtime patching on workerd | Build with the Vite plugin (`useDiagnosticsChannelInjection: true`) **or** wrap the client with `Sentry.instrument*Client` |
|
|
648
|
+
| Vite plugin injection has no effect | Missing `nodejs_compat` flag, or SDK < 10.68.0 | Add `nodejs_compat` to `compatibility_flags`; upgrade `@sentry/cloudflare` |
|
|
649
|
+
| Vercel AI spans missing | Integration not added, or telemetry not enabled per call | Add `Sentry.vercelAIIntegration()` to `integrations` and `experimental_telemetry: { isEnabled: true }` on every call |
|
|
650
|
+
| Vercel AI SDK v7 not working | Default entrypoint doesn’t support v7 | Use `@sentry/cloudflare/nodejs_compat` (SDK >=10.64.0) — see `./nodejs-compat.md` |
|
|
651
|
+
| Workers AI calls not traced | `env` accessed outside the wrapped handler, or SDK < 10.67.0 | Use the `env` passed into the handler; upgrade the SDK |
|
|
652
|
+
| Duplicate spans for AI calls made through the Vercel AI SDK (`workers-ai-provider`) | SDK < 10.69.0: both the Vercel AI integration and the Workers AI binding instrumentation recorded the same call | Upgrade to 10.69.0+ — the binding instrumentation now skips calls the Vercel AI integration is already recording |
|
|
653
|
+
| LangChain/LangGraph not traced | Expecting Vite plugin coverage | Not covered by channel injection — use `createLangChainCallbackHandler` / `instrumentLangGraph` |
|
|
654
|
+
| Agents SDK chats not grouping | Agent wrapped with `instrumentDurableObjectWithSentry`, or SDK < 10.69.0 | Wrap with `instrumentAgentWithSentry` (v10.69.0+) for automatic conversation IDs, or call `setConversationId` manually in `onChatMessage` |
|
|
655
|
+
| Agents SDK conversation split unexpectedly | Chat was cleared — `clearHistory()` (or anything emitting `message:clear`) rotates to a fresh conversation ID by design | Expected: a reset chat groups as a new conversation |
|
|
656
|
+
| One giant conversation across users | Agent instance name is per-user or a shared singleton (e.g. `"default"`) | Use one agent instance per chat session, or override with `Sentry.setConversationId(chatSessionId)` per turn |
|
|
657
|
+
| Prompts/responses not captured | genAI capture disabled | Don’t set `dataCollection: { genAI: { inputs: false } }`, or pass `recordInputs`/`recordOutputs: true` explicitly |
|
|
658
|
+
| Conversations view empty | No conversation ID, or gen_ai streaming disabled | Call `Sentry.setConversationId()` before AI calls; keep `streamGenAiSpans` at its default (`true`) |
|
|
659
|
+
| Self-hosted: gen_ai spans dropped | Standalone gen_ai envelopes not ingested | Set `streamGenAiSpans: false` |
|
|
660
|
+
| User column shows “Unknown” | No user on the scope | Call `Sentry.setUser()` once per request before AI calls |
|
|
661
|
+
| Wrong/negative cost calculations | Token subsets reported as totals | `input_tokens`/`output_tokens` must be totals that _include_ cached/reasoning counts |
|