feat(ai): Attach granular cost data to spans#6167
Merged
Merged
Conversation
vgrozdanic
force-pushed
the
vg/granular-cost-attrs-and-otel-renames
branch
2 times, most recently
from
July 15, 2026 13:29
72bc739 to
6e66700
Compare
… cost fields Rename three SpanData usage fields to their new OTEL semantic convention names, keeping the old names as legacy_alias for backward compatibility: - gen_ai.usage.input_tokens.cached → gen_ai.usage.cache_read.input_tokens - gen_ai.usage.input_tokens.cache_write → gen_ai.usage.cache_creation.input_tokens - gen_ai.usage.output_tokens.reasoning → gen_ai.usage.reasoning.output_tokens Add three new granular cost fields mirroring the usage token breakdown: - gen_ai.cost.cache_read.input_tokens - gen_ai.cost.cache_creation.input_tokens - gen_ai.cost.reasoning.output_tokens Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
vgrozdanic
force-pushed
the
vg/granular-cost-attrs-and-otel-renames
branch
from
July 15, 2026 13:38
6e66700 to
64c8410
Compare
vgrozdanic
force-pushed
the
vg/granular-cost-attrs-and-otel-renames
branch
from
July 15, 2026 14:41
64c8410 to
4bc177b
Compare
vgrozdanic
marked this pull request as ready for review
July 15, 2026 14:57
Dav1dde
approved these changes
Jul 16, 2026
Dav1dde
left a comment
Member
There was a problem hiding this comment.
Integration tests need fixing/changing
Cost calculation now always emits cache_read, cache_creation, and reasoning cost fields. Update the AI span integration fixture so those zero values are asserted. Co-Authored-By: x-ai/grok-4.5 <noreply@opencode.ai>
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Jul 16, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Jul 16, 2026
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.
Since we introduced cost calculation we were correctly calculating the cost by taking into account input, cached, output and reasoning tokens, but we have never attached that information to spans.
We already have this attributes in our conventions since forever, this PR just adds the better cost breakdown to spans