Repository navigation
feat(ai): Add gen_ai.response.tokens_per_second span attribute on AI spans - #4883
Merged
Merged
Conversation
vgrozdanic
force-pushed
the
vg/tokens-per-second-calculation
branch
from
July 1, 2025 12:04
f18e68b to
8341652
Compare
vgrozdanic
marked this pull request as ready for review
July 1, 2025 12:30
loewenheim
approved these changes
Jul 1, 2025
| "spans": [ | ||
| { | ||
| "timestamp": 1702474613.0495, | ||
| "timestamp": 1702474614.0175, |
Contributor
There was a problem hiding this comment.
I assume this is so the span lasts for exactly 1s?
Member
Author
There was a problem hiding this comment.
yes, to avoid floating point errors in tests, and make it easier to write tests :)
Dav1dde
approved these changes
Jul 2, 2025
Dav1dde
left a comment
Member
There was a problem hiding this comment.
I assume you're also updating the sentry conventions repo?
Comment on lines
+2667
to
+2673
| let span_data = event | ||
| .value() | ||
| .and_then(|event| event.spans.value()) | ||
| .and_then(|spans| spans.first()) | ||
| .and_then(|span| span.value()) | ||
| .and_then(|span| span.data.value()) | ||
| .unwrap(); |
Member
There was a problem hiding this comment.
The get_value! macro should work here
Member
Author
There was a problem hiding this comment.
TIL, this is really cool macro, thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds new span attribute
gen_ai.response.tokens_per_seconddefined by Nvidia.This is calculated as:
output_tokens / span.durationCloses TET-618: tokens per second