feat(attributes): Add additional_context to gen_ai cost and usage attributes#397
Merged
Conversation
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
🤖 This preview updates automatically when you update the PR. |
Lms24
approved these changes
May 21, 2026
Member
Lms24
left a comment
There was a problem hiding this comment.
One request:
Can we add a changelog entry to each attribute where we added the additional context fields?
Something along the lines of:
{
"version": "next",
"prs": [397],
"description": "Add additional_context"
}
Otherwise LGTM!
…ributes Populates the `additional_context` field (introduced in #393) for all 11 gen_ai cost and usage attributes. Each attribute gets notes about: - Double-counting: all cost/usage attributes appear on both agent parent spans (aggregated totals) and LLM child spans (per-call values). Summing without filtering to gen_ai.operation.type:ai_client will over-report. - Naming confusion: cost attributes contain USD values despite having "tokens" in the name. - Subset relationships: cached input tokens are a subset of input tokens, reasoning tokens are a subset of output tokens, and total tokens is the sum of input + output. These should not be summed together. Attributes updated: - gen_ai.cost.input_tokens, gen_ai.cost.output_tokens, gen_ai.cost.total_tokens - gen_ai.usage.input_tokens, gen_ai.usage.input_tokens.cached, gen_ai.usage.input_tokens.cache_write - gen_ai.usage.output_tokens, gen_ai.usage.output_tokens.reasoning - gen_ai.usage.total_tokens - gen_ai.usage.completion_tokens (deprecated), gen_ai.usage.prompt_tokens (deprecated)
9f16a4b to
09a03ed
Compare
matejminar
added a commit
that referenced
this pull request
May 21, 2026
Surfaces the `additional_context` field (added in #393, populated in #397) in the Astro docs site and the plain text LLM export. Changes: - content.config.ts: Added additional_context to the Zod schema - AttributeCard.astro: Renders notes as a collapsible section (open by default) above the changelog, matching the existing disclosure pattern - llms-full.txt.ts: Includes additional_context as nested list items in the plain text export for LLM consumption
matejminar
added a commit
that referenced
this pull request
May 21, 2026
Surfaces the `additional_context` field (added in #393, populated in #397) in the Astro docs site and the plain text LLM export. Changes: - content.config.ts: Added additional_context to the Zod schema - AttributeCard.astro: Renders notes as a collapsible section (open by default) above the changelog, matching the existing disclosure pattern - llms-full.txt.ts: Includes additional_context as nested list items in the plain text export for LLM consumption
matejminar
added a commit
that referenced
this pull request
May 21, 2026
…rt (#399) Surfaces the `additional_context` field (added in #393, populated in #397) in the Astro docs site and the plain text LLM export. Changes: - content.config.ts: Added additional_context to the Zod schema - AttributeCard.astro: Renders notes as a collapsible section (open by default) above the changelog, matching the existing disclosure pattern - llms-full.txt.ts: Includes additional_context as nested list items in the plain text export for LLM consumption
4 tasks
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.
Populates the
additional_contextfield (introduced in #393) for all 11 gen_ai cost and usage attributes.Context
Each attribute gets notes about:
gen_ai.operation.type:ai_clientwill over-report.Attributes updated
gen_ai.cost.total_tokensgen_ai.cost.input_tokensgen_ai.cost.output_tokensgen_ai.usage.input_tokensgen_ai.usage.input_tokens.cachedgen_ai.usage.input_tokens.cache_writegen_ai.usage.output_tokensgen_ai.usage.output_tokens.reasoninggen_ai.usage.total_tokensgen_ai.usage.completion_tokens(deprecated)gen_ai.usage.prompt_tokens(deprecated)See proposal: https://www.notion.so/sentry/Proposal-Query-Guidance-for-Span-Attributes-3598b10e4b5d806d8c75e2a5b1caa42c
Closes TET-2316, TET-2317