Skip to content

Use span.data instead of measurements for token usage #4567

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

Merged
merged 1 commit into from
Jul 10, 2025

Conversation

antonpirker
Copy link
Member

@antonpirker antonpirker commented Jul 10, 2025

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

Copy link

codecov bot commented Jul 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.73%. Comparing base (5709b25) to head (a2f9f0b).
Report is 2 commits behind head on master.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4567      +/-   ##
==========================================
+ Coverage   80.72%   80.73%   +0.01%     
==========================================
  Files         156      156              
  Lines       16481    16481              
  Branches     2801     2801              
==========================================
+ Hits        13304    13306       +2     
- Misses       2295     2296       +1     
+ Partials      882      879       -3     
Files with missing lines Coverage Δ
sentry_sdk/ai/monitoring.py 86.30% <100.00%> (ø)

... and 3 files with indirect coverage changes

@antonpirker antonpirker marked this pull request as ready for review July 10, 2025 08:00
@antonpirker antonpirker requested a review from a team as a code owner July 10, 2025 08:00
@antonpirker antonpirker merged commit 6f71a1b into master Jul 10, 2025
137 checks passed
@antonpirker antonpirker deleted the antonpirker/data-instead-of-measurements branch July 10, 2025 13:11
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.

2 participants