Repository navigation
fix(server-utils): Use the client's provider name for Anthropic platform clients - #26119
Conversation
…orm clients `AnthropicBedrock` and the SDK's other platform clients reuse the `@anthropic-ai/sdk` `Messages` resource, so their calls already get gen_ai spans, but the spans said `gen_ai.provider.name: anthropic`. The SDK stores the platform name on the client as `_genAIProviderName` (`aws.bedrock` for Bedrock), so read it from the resource's client. Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
size-limit report 📦Compared: 565dd43 (PR test merge using develop at c7d73e4) Against: c7d73e4 (develop) · base run #66026 ✅ Baseline matches: this diff contains only this PR's changes.
|
Optional E2E testsSome optional checks were not successful. They do not block the merge. 4 not successful, 54 successful. See the run.
Successful checks
|
…ock-provider-name # Conflicts: # dev-packages/node-integration-tests/suites/tracing/anthropic/v1/test.ts
…ock-provider-name # Conflicts: # packages/server-utils/src/ai/anthropic-ai/index.ts # packages/server-utils/src/ai/anthropic-ai/utils.ts # packages/server-utils/test/ai/lib/utils/anthropic-utils.test.ts
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 308099d. Configure here.
| messages: [{ role: 'user', content: 'Hello' }], | ||
| }); | ||
|
|
||
| expect(spanToStaticSpanJSON(endedSpans[0]!).data['gen_ai.provider.name']).toBe(expected); |
There was a problem hiding this comment.
Test uses hardcoded attribute name
Low Severity
The new unit test asserts gen_ai.provider.name with a string literal. Review rules ask span-attribute assertions in tests to use the matching @sentry/conventions/attributes constant, which sibling tests in this package already do. Flagged because that convention is in the review rules.
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit 308099d. Configure here.


Why:
AnthropicBedrock(@anthropic-ai/bedrock-sdk) extendsBaseAnthropicand builds itsmessagesfrom@anthropic-ai/sdk's ownMessagesclass. Our orchestrion hooks on that file already trace it, with prompts, responses, and usage, and with no duplicate native OTel span. I checked this against the real@anthropic-ai/bedrock-sdk@1.1.1. The one gap was that the spans saidgen_ai.provider.name: anthropic. The SDK stores the platform on the client as_genAIProviderName(aws.bedrockon Bedrock). This reads that value from the resource's client and falls back toanthropic.How to review: The change is in
getProviderNameand its two call sites. The integration scenario subclassesAnthropicand sets_genAIProviderNamethe same wayAnthropicBedrockdoes, so no new dev dependency is needed.Unsure about:
_genAIProviderNameis marked@internalin the SDK. bedrock-sdk sets it from 0.35.0 on; 0.34.4 and earlier keep reportinganthropic. Only the Bedrock clients (AnthropicBedrock,AnthropicBedrockMantle→aws.bedrock) and Vertex (gcp.vertex_ai) set it.AnthropicFoundryandAnthropicAwsdon't, so they still reportanthropic.Closes #19154
via @sergical.
--
View Session [Sentry]