-
Notifications
You must be signed in to change notification settings - Fork 103
feat(ai): data & measurement normalization #4768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
"measurements": { | ||
"ai_total_tokens_used": { | ||
"value": 20 | ||
}, | ||
"ai_total_cost": { | ||
"value": 0.0002 | ||
} | ||
}, | ||
"data": { | ||
"gen_ai.usage.total_tokens": 20, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the total cost measurement removed? A corresponding field exists in data
, right?
Side note: should we move this test input out of the file? It's literally over 1000 lines long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Talk with Anton and apparently that is never send by the SDKs in the first place, so I removed it to keep the test consistent with the real world.
...on/snapshots/relay_server__metrics_extraction__event__tests__both_feature_flags_enabled.snap
Show resolved
Hide resolved
...traction/snapshots/relay_server__metrics_extraction__event__tests__extract_span_metrics.snap
Outdated
Show resolved
Hide resolved
.and_then(|span| span.value()) | ||
.and_then(|span| span.data.value()) | ||
.and_then(|data| data.gen_ai_usage_total_cost.value()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
…ry/relay into tobias-wilfert/feat/normalize-ai
Access span properties via the new keys while also using the old ones as fallback. - part of [TET-498: Trace View - AI Span details](https://linear.app/getsentry/issue/TET-498/trace-view-ai-span-details) - relay started mapping to new keys in getsentry/relay#4768
Access span properties via the new keys while also using the old ones as fallback. - part of [TET-498: Trace View - AI Span details](https://linear.app/getsentry/issue/TET-498/trace-view-ai-span-details) - relay started mapping to new keys in getsentry/relay#4768
resolves #16453 In getsentry/sentry-conventions#57 we deprecated some of the `ai.X` attributes in favour of OTEL's `gen_ai.X` attributes. This updates the Vercel AI integration to address these deprecations. These changes are based on https://ai-sdk.dev/docs/ai-sdk-core/telemetry#collected-data, and we created `attributes.ts` to track these as constants. See the relay change here to switch to new attributes for measuring token usage: getsentry/relay#4768
Store AI token usage in `span.data` instead of deprecated `measurements`. In `relay` there is already code in place that copies the data from the deprecated `span.measurements` to `span.data` and uses `span.data` for calculating the cost of token usage. So this PR can be deployed in a minor without risk. See also `relay` PR: getsentry/relay#4768
Maps old and depreciated
measurements
anddata
to new fields in line with our conventions.Fixes: https://linear.app/getsentry/issue/RELAY-69/normalise-ai-related-span-data
Updates cost calcuation and metric extraction to use
data
rather thanmeasurements
.Fixes: https://linear.app/getsentry/issue/RELAY-70/update-metrics-extraction-to-new-span-data-names