-
Notifications
You must be signed in to change notification settings - Fork 64
feat(google-genai): extract modality token usage attributes on generate_content #674
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
lmolkova
merged 8 commits into
open-telemetry:main
from
Krishnachaitanyakc:google-genai-modality-token-usage
Sep 16, 2026
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cb50b61
feat(google-genai): extract modality token usage attributes on genera…
Krishnachaitanyakc 0530570
Add changelog fragment
Krishnachaitanyakc 1680397
Merge branch 'main' into google-genai-modality-token-usage
Krishnachaitanyakc d1a3a1a
refactor(util-genai): own the modality token mapping on InferenceInvo…
Krishnachaitanyakc 72c44f9
Merge branch 'main' into google-genai-modality-token-usage
Krishnachaitanyakc 12ba4b1
Avoid walking property paths on every intermediate streaming chunk th…
Krishnachaitanyakc 7dd8e9c
Merge remote-tracking branch 'origin/main' into google-genai-modality…
Krishnachaitanyakc 2c9dadb
Apply ruff format
Krishnachaitanyakc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
instrumentation/opentelemetry-instrumentation-google-genai/.changelog/674.added
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Record modality token usage breakdown attributes (text, image, audio) for generate_content. |
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
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
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
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.
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.
This is the third copy of this mapping -
interactions.pyhas one and langchain got one in #671. Let's move this ontoInferenceInvocationinopentelemetry-util-genaiinstead of duplicating and trying to unify later.Rough sketch (not final, needs details sorted out):
Call site here simplifies to:
This removes the local dicts, enum/string normalization, and int checks. It also centralizes handling unmapped modalities and future token types across all instrumentations.
Note:
Modalityintypes.pycurrently lackstext, need to add it.It's a small change - let's add the util method and update
interactions.pyand langchain right awayThere 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.
Makes sense, pushed in d1a3a1a. Went with the whole iterable rather than per entry, so an arriving breakdown replaces rather than merges. Happy to switch.
interactions.pyis in there, which #616 also touches.