Skip to content

Conversation

RulaKhaled
Copy link
Member

With the relay now handling cache token attributes (instead of scrubbing them), some Anthropic related token attributes were still missing. This PR adds the missing cache attributes and corrects the types in the Anthropic provider metadata used for extracting token data.

Fixes: #17890

@linear
Copy link

linear bot commented Oct 21, 2025

@RulaKhaled RulaKhaled marked this pull request as ready for review October 21, 2025 12:39
@RulaKhaled RulaKhaled requested review from JPeer264 and s1gr1d October 21, 2025 12:39
cursor[bot]

This comment was marked as outdated.

* The number of cached input tokens that were used
* @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#basic-llm-span-information
*/
export const AI_USAGE_CACHED_INPUT_TOKENS_ATTRIBUTE = 'ai.usage.cachedInputTokens';
Copy link
Member

Choose a reason for hiding this comment

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

l: I couldn't find the ai.usage.cachedInputTokens in the given docs. Not sure if that is wanted

Copy link
Member Author

Choose a reason for hiding this comment

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

it exists in their otel attributes, unfortunately not everything is documented.
Screenshot 2025-10-21 at 3 16 04 PM

@github-actions
Copy link
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 24.64 kB - -
@sentry/browser - with treeshaking flags 23.14 kB - -
@sentry/browser (incl. Tracing) 40.99 kB - -
@sentry/browser (incl. Tracing, Profiling) 45.28 kB - -
@sentry/browser (incl. Tracing, Replay) 79.31 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 68.99 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 84.02 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 96.17 kB - -
@sentry/browser (incl. Feedback) 41.33 kB - -
@sentry/browser (incl. sendFeedback) 29.3 kB - -
@sentry/browser (incl. FeedbackAsync) 34.26 kB - -
@sentry/react 26.35 kB - -
@sentry/react (incl. Tracing) 42.99 kB - -
@sentry/vue 29.13 kB - -
@sentry/vue (incl. Tracing) 42.79 kB - -
@sentry/svelte 24.66 kB - -
CDN Bundle 26.94 kB - -
CDN Bundle (incl. Tracing) 41.65 kB - -
CDN Bundle (incl. Tracing, Replay) 77.91 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 83.37 kB - -
CDN Bundle - uncompressed 78.95 kB - -
CDN Bundle (incl. Tracing) - uncompressed 123.53 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 238.57 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 251.33 kB - -
@sentry/nextjs (client) 45.13 kB - -
@sentry/sveltekit (client) 41.42 kB - -
@sentry/node-core 50.78 kB +0.01% +1 B 🔺
@sentry/node 154.46 kB +0.04% +54 B 🔺
@sentry/node - without tracing 92.66 kB - -
@sentry/aws-serverless 106.35 kB - -

View base workflow run

@github-actions
Copy link
Contributor

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 8,921 - 11,747 -24%
GET With Sentry 1,394 16% 1,647 -15%
GET With Sentry (error only) 6,104 68% 7,767 -21%
POST Baseline 1,227 - 1,206 +2%
POST With Sentry 521 42% 543 -4%
POST With Sentry (error only) 1,080 88% 1,034 +4%
MYSQL Baseline 3,384 - 4,014 -16%
MYSQL With Sentry 521 15% 551 -5%
MYSQL With Sentry (error only) 2,768 82% 3,352 -17%

View base workflow run

@RulaKhaled RulaKhaled merged commit 75f68c7 into develop Oct 21, 2025
193 checks passed
@RulaKhaled RulaKhaled deleted the rolaabuhasna/js-1035-vercelai-instrumentation-missing-cached-token-usage-data branch October 21, 2025 13:13
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.

VercelAI instrumentation missing cached token usage data

2 participants