feat(schema): Add additional_context field to attribute definitions#393
Merged
Conversation
Adds a new optional `additional_context` field to attribute definitions — a list of freeform notes capturing query-time nuances, common pitfalls, or behavioral context that isn't covered by `brief`. Span attributes can have subtleties that trip up both users and AI agents when querying. For example, `gen_ai.cost.total_tokens` appears on both agent parent spans and LLM child spans, causing `sum()` queries to double-count. Today there's nowhere to capture this kind of context — `brief` describes *what* the attribute is, not *how to use it correctly*. This is the foundation for surfacing attribute context to Explore UI (via Seer) and AI agent tooling. A follow-up PR will populate the field for gen_ai cost and usage attributes. See proposal: https://www.notion.so/sentry/Proposal-Query-Guidance-for-Span-Attributes-3598b10e4b5d806d8c75e2a5b1caa42c Changes: - Schema: New optional `additional_context` property (array of strings) in `attribute.schema.json` - Types: Added to `AttributeJson` interface in `types.ts` - Codegen: Updated JS and Python generators to propagate the field into `AttributeMetadata` (as `additionalContext` in JS, `additional_context` in Python) - Generated code: Regenerated JS and Python packages with the new field
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Attributes
Other
Bug Fixes 🐛Attributes
Other
Internal Changes 🔧Deps
Other
🤖 This preview updates automatically when you update the PR. |
Lms24
approved these changes
May 20, 2026
Member
Lms24
left a comment
There was a problem hiding this comment.
nice, LGTM! We most likely also want to show this field in our Astro docs but we can tackle that as a follow-up PR once we also add the field to some attributes.
This was referenced May 21, 2026
matejminar
added a commit
that referenced
this pull request
May 21, 2026
…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)
matejminar
added a commit
that referenced
this pull request
May 21, 2026
…ributes (#397) 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)
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.
Adds a new optional
additional_contextfield to attribute definitions — a list of freeform notes capturing query-time nuances, common pitfalls, or behavioral context that isn't covered bybrief.Motivation
Span attributes can have subtleties that trip up both users and AI agents when querying. For example,
gen_ai.cost.total_tokensappears on both agent parent spans and LLM child spans, causingsum()queries to double-count. Today there's nowhere to capture this kind of context —briefdescribes what the attribute is, not how to use it correctly.This is the foundation for surfacing attribute context to Explore UI (via Seer) and AI agent tooling. A follow-up PR will populate the field for gen_ai cost and usage attributes.
See proposal: https://www.notion.so/sentry/Proposal-Query-Guidance-for-Span-Attributes-3598b10e4b5d806d8c75e2a5b1caa42c
Changes
additional_contextproperty (array of strings) inattribute.schema.jsonAttributeJsoninterface intypes.tsAttributeMetadata(asadditionalContextin JS,additional_contextin Python)Closes TET-2319, TET-2315