Skip to content

fix(server-utils): Instrument @anthropic-ai/sdk 1.x and turn off its own OTel spans - #25750

Open
RulaKhaled wants to merge 5 commits into
developfrom
fix/anthropic-sdk-1x
Open

RulaKhaled wants to merge 5 commits into
developfrom
fix/anthropic-sdk-1x

Conversation

@RulaKhaled

Copy link
Copy Markdown
Collaborator

Our Anthropic instrumentation was capped at <1, so @anthropic-ai/sdk 1.x wasn't instrumented. 1.x also emits its own OTel spans, and they reach Sentry wherever we register the global tracer provider (the default in Next.js, SvelteKit and Vercel Edge). Raising the range alone gave two spans per call.

This raises the range to <2 and sets ANTHROPIC_OPEN_TELEMETRY=false unless the user set it, the same way we disable Next.js' own fetch spans with NEXT_OTEL_FETCH_DISABLED.

Follow-up. Tool-runner chat spans don't reach Sentry on 1.x yet.

Fixes #25748

🤖 Generated with Claude Code

…own OTel spans

Raise the orchestrion range to <2 (Completions stays <1, removed in 1.0) and set
ANTHROPIC_OPEN_TELEMETRY=false unless the user set it, so 1.x's native spans don't
duplicate ours where Sentry registers the global tracer provider.

Fixes #25748

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: 0a20ba4 (PR test merge using develop at b364030)

Against: b364030 (develop) · base run #64096

✅ Baseline matches: this diff contains only this PR's changes.

Path Size % Change Change
@sentry/browser 30.39 kB - -
@sentry/browser - with treeshaking flags 28.5 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.4 kB - -
@sentry/browser (incl. Tracing) 52.66 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.66 kB - -
@sentry/browser (incl. Tracing, Profiling) 55.59 kB - -
@sentry/browser (incl. Tracing, Replay) 92.89 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.5 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 97.63 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 110.6 kB - -
@sentry/browser (incl. Feedback) 47.95 kB - -
@sentry/browser (incl. sendFeedback) 35.47 kB - -
@sentry/browser (incl. FeedbackAsync) 40.57 kB - -
@sentry/browser (incl. Metrics) 31.4 kB - -
@sentry/browser (incl. Logs) 31.68 kB - -
@sentry/browser (incl. Metrics & Logs) 32.36 kB - -
@sentry/react 32.2 kB - -
@sentry/react (incl. Tracing) 54.94 kB - -
@sentry/vue 38.67 kB - -
@sentry/vue (incl. Tracing) 55.55 kB - -
@sentry/svelte 30.42 kB - -
@sentry/remix (Remix 3 client bundle) 57.71 kB - -
CDN Bundle 32.11 kB - -
CDN Bundle (incl. Tracing) 53.14 kB - -
CDN Bundle (incl. Logs, Metrics) 34.31 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 55.09 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 75.76 kB - -
CDN Bundle (incl. Tracing, Replay) 91.3 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 93.26 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 97.44 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 99.44 kB - -
CDN Bundle - uncompressed 94.47 kB - -
CDN Bundle (incl. Tracing) - uncompressed 157.46 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 101.02 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 163.43 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 232.57 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 279.15 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 285.1 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 292.85 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 298.79 kB - -
@sentry/nextjs (client) 57.79 kB - -
@sentry/sveltekit (client) 53.11 kB - -
@sentry/core/server 44.34 kB - -
@sentry/core/browser 13.95 kB - -
@sentry/node 155.14 kB +0.04% +61 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.67 kB -0.01% -2 B 🔽
@sentry/node - without tracing 95.84 kB +0.03% +24 B 🔺
@sentry/node - without channel injection 135.78 kB +0.05% +66 B 🔺
@sentry/aws-serverless 104.01 kB +0.03% +24 B 🔺
@sentry/cloudflare (withSentry) - minified 198.01 kB - -
@sentry/cloudflare (withSentry) 491.83 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 218.59 kB - -

View base workflow run

With ANTHROPIC_OPEN_TELEMETRY=false the client has no tracer and injects no
headers, so propagation is left to our HTTP instrumentation, which its own
suites cover.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

All optional checks were successful. 57 successful. See the run.

Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E astro-7 Test (optional) Successful in 52s Details
✅ CI: Optional E2E Tests / E2E cloudflare-think (ai v6) Test (optional) Successful in 34s Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (cloudflare) Test (optional) Successful in 58s Details
✅ CI: Optional E2E Tests / E2E astro-7-static Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-flue Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-flue-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E deno (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-think Test (optional) Successful in 45s Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries Test (optional) Successful in 31s Details
✅ CI: Optional E2E Tests / E2E node-anthropic-send-to-sentry (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-mastra Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-anthropic-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (latest) Test (optional) Successful in 28s Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 (tracer provider) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-mastra Test (optional) Successful in 48s Details
✅ CI: Optional E2E Tests / E2E supabase-nextjs Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-pi-durable (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E debug-id-sourcemaps Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-agent Test (optional) Successful in 47s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 Test (optional) Successful in 14s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry-static Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-send-to-sentry Test (optional) Successful in 5m Details
✅ CI: Optional E2E Tests / E2E react-router-7-framework-instrumentation Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-orpc Test (optional) Successful in 53s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (cloudflare, latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 Test (optional) Successful in 21s Details
✅ CI: Optional E2E Tests / E2E node-eve (orchestrion) Test (optional) Successful in 37s Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-mastra (latest) Test (optional) Successful in 44s Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v1 Test (optional) Successful in 39s Details
✅ CI: Optional E2E Tests / E2E nextjs-14 (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-pi-durable Test (optional) Successful in 52s Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable (latest) Test (optional) Successful in 25s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 20s Details
✅ CI: Optional E2E Tests / E2E node-eve Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E react-send-to-sentry Test (optional) Successful in 4m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (deno) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-openai-send-to-sentry (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions (latest) Test (optional) Successful in 15s Details
✅ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Successful in 37s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps Test (optional) Successful in 30s Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 Test (optional) Successful in 43s Details
✅ CI: Optional E2E Tests / E2E vue-3 (no Options API) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 27s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 39s Details
✅ CI: Optional E2E Tests / E2E node-eve (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-openai-send-to-sentry Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E node-flue (latest) Test (optional) Successful in 1m Details

@chargome

Copy link
Copy Markdown
Member

The tool-runner chat span follow-up is now tracked in #25816. The cause is message threads, added in 1.2.0. The thread awaits request._responseProps() and parses the response itself, so wrapApiPromiseResponse never ends the span. 1.0.0 and 1.1.0 still produce the chat spans.

mydea added a commit that referenced this pull request Oct 28, 2026
**Why:** Two optional E2E apps fail on `develop`, independent of any PR:

- `node-anthropic-send-to-sentry (latest)` doesn't compile:
`@anthropic-ai/sdk` 1.0 moved to API version `2026-10-21`, which removed
`temperature` from message params. The app source is shared with the
pinned 0.63.0 variant, so it drops `temperature` and the e2e no longer
asserts `gen_ai.request.temperature`. Request params stay covered by
`node-integration-tests`.
- `node-openai-decisions-send-to-sentry` (both variants) still expected
the Vercel AI origin `auto.vercelai.channel` from before #25602 renamed
it to `auto.ai.vercelai`.

**Depends on:** #25750. Our Anthropic instrumentation only matches SDK
versions `<1`, so the latest variant compiles with this PR but still
produces no gen_ai spans until #25750 raises the range.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
});
}
},
{ additionalDependencies: { '@anthropic-ai/sdk': '1.3.0' } },

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.

no strong feelings, but maybe it is worth it to invert it - so bump the version in node-integrationt-tests to 1.3.0, and add a test for the older version specifically?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! so the main suite passed on 1.x as is apart from completions.create which 1.0 removed. that went into a new v0/ suite which also runs create, beta, streaming and the stream helper so 0.x still gets more than just completions

The main Anthropic suite now runs on @anthropic-ai/sdk 1.3.0. It passes
unchanged apart from `completions.create`, which 1.0 removed. That call
moves to a new `v0/` suite pinned to 0.133.0, which also runs the
`messages` calls so 0.x keeps a smoke test.

Bun runs neither the `v0/` nor the `v1/` suite, like the other Anthropic
suites: `bun run` does not inject the diagnostics channels.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@RulaKhaled
RulaKhaled marked this pull request as ready for review October 29, 2026 10:09
@RulaKhaled
RulaKhaled requested review from a team as code owners October 29, 2026 10:09
@RulaKhaled
RulaKhaled requested review from chargome, isaacs, msonnb and mydea and removed request for a team October 29, 2026 10:09

@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 9e56a0e. Configure here.

Comment thread packages/server-utils/src/orchestrion/config/anthropic-ai.ts
The SessionToolRunner entry landed on develop after the other Anthropic
ranges were raised, so it still stopped at `<1`. 1.x ships the same
class at the same path, so its tool runs got no `execute_tool` spans.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

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.

Anthropic SDK 1.x is not instrumented on Node and emits its own OTel spans

4 participants