Repository navigation
feat(develop-docs): Render span attributes from sentry-conventions #20638
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
cleptric
merged 10 commits into
master
from
cleptric/feat/convention-attributes-component
Nov 10, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2c2e0e2
feat(develop-docs): Render span attributes from sentry-conventions
sentry-junior[bot] 70f0656
ref(develop-docs): Simplify ConventionAttributes component
dingsdax 4ffe5a9
feat(develop-docs): Render all AI agent attribute tables from convent…
cleptric 84c2e9e
ref(develop-docs): Tighten ConventionAttributes table rendering
cleptric 97ba009
ref(develop-docs): Bump @sentry/conventions to 0.32.0
cleptric c3c9aeb
ref(develop-docs): Drop footnotes covered by convention briefs
cleptric 4642f14
build(develop-docs): Use unreleased @sentry/conventions from main
cleptric 10c2c13
build(develop-docs): Update vendored @sentry/conventions to b14f1e56
cleptric 3ff0ac7
ref(develop-docs): Inline the invoke_agent span name footnote
cleptric 8c164b3
build(develop-docs): Use published @sentry/conventions 0.33.0
cleptric 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,61 @@ | ||
| import {ATTRIBUTE_METADATA} from '@sentry/conventions/attributes'; | ||
| import React from 'react'; | ||
| import {renderToStaticMarkup} from 'react-dom/server'; | ||
| import {describe, expect, it, vi} from 'vitest'; | ||
|
|
||
| import {ConventionAttributes} from './index'; | ||
|
|
||
| // Vitest compiles JSX with the classic runtime here (tsconfig `jsx: preserve`). | ||
| vi.stubGlobal('React', React); | ||
|
|
||
| describe('ConventionAttributes', () => { | ||
| it('renders attributes from the conventions package', () => { | ||
| const html = renderToStaticMarkup( | ||
| <ConventionAttributes attributes={['gen_ai.tool.name']} /> | ||
| ); | ||
|
|
||
| expect(html).toContain('<code>gen_ai.tool.name</code>'); | ||
| expect(html).toContain(ATTRIBUTE_METADATA['gen_ai.tool.name'].type); | ||
| expect(html).toContain(ATTRIBUTE_METADATA['gen_ai.tool.name'].brief); | ||
| }); | ||
|
|
||
| it('appends page-specific notes to the description', () => { | ||
| const html = renderToStaticMarkup( | ||
| <ConventionAttributes | ||
| attributes={[{key: 'gen_ai.usage.input_tokens', notes: '**[2]**'}]} | ||
| /> | ||
| ); | ||
|
|
||
| expect(html).toContain('<strong>[2]</strong>'); | ||
| }); | ||
|
|
||
| it('throws on unknown attributes so the build fails', () => { | ||
| expect(() => | ||
| renderToStaticMarkup(<ConventionAttributes attributes={['gen_ai.not.a.thing']} />) | ||
| ).toThrow('unknown attribute "gen_ai.not.a.thing"'); | ||
| }); | ||
|
|
||
| it('throws on keys inherited from Object.prototype', () => { | ||
| expect(() => | ||
| renderToStaticMarkup(<ConventionAttributes attributes={['constructor']} />) | ||
| ).toThrow('unknown attribute "constructor"'); | ||
| }); | ||
|
|
||
| it('single-quotes stringified JSON examples', () => { | ||
| const html = renderToStaticMarkup( | ||
| <ConventionAttributes | ||
| attributes={['gen_ai.tool.call.arguments', 'gen_ai.tool.name']} | ||
| /> | ||
| ); | ||
|
|
||
| expect(html).toContain( | ||
| `<code>'${ATTRIBUTE_METADATA['gen_ai.tool.call.arguments'].example}'</code>`.replaceAll( | ||
| '"', | ||
| '"' | ||
| ) | ||
| ); | ||
| expect(html).toContain( | ||
| `<code>"${ATTRIBUTE_METADATA['gen_ai.tool.name'].example}"</code>` | ||
| ); | ||
| }); | ||
| }); |
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,72 @@ | ||
| import { | ||
| ATTRIBUTE_METADATA, | ||
| type AttributeMetadata, | ||
| type AttributeValue, | ||
| } from '@sentry/conventions/attributes'; | ||
| import {micromark} from 'micromark'; | ||
|
|
||
| type Props = { | ||
| attributes: (string | {key: string; notes?: string})[]; | ||
| }; | ||
|
|
||
| const metadata: Record<string, AttributeMetadata> = ATTRIBUTE_METADATA; | ||
|
|
||
| /** | ||
| * Renders attribute details from `@sentry/conventions`, so pages don't copy | ||
| * types, descriptions, and examples that drift from the source of truth. | ||
| */ | ||
| export function ConventionAttributes({attributes}: Props) { | ||
| const rows = attributes.map(row => { | ||
| const {key, notes} = typeof row === 'string' ? {key: row} : row; | ||
| // `Object.hasOwn` so keys like `constructor` don't pass as known attributes. | ||
| const attribute = Object.hasOwn(metadata, key) ? metadata[key] : undefined; | ||
| if (!attribute) { | ||
| throw new Error(`<ConventionAttributes>: unknown attribute "${key}"`); | ||
| } | ||
| const description = micromark([attribute.brief, notes].filter(Boolean).join(' ')) | ||
| .replace(/^<p>/, '') | ||
| .replace(/<\/p>$/, ''); | ||
| return {key, attribute, description}; | ||
| }); | ||
|
|
||
| return ( | ||
| <table> | ||
| <thead> | ||
| <tr> | ||
| <th>Attribute</th> | ||
| <th>Type</th> | ||
| <th>Description</th> | ||
| <th>Example</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| {rows.map(({key, attribute, description}) => ( | ||
| <tr key={key}> | ||
| <td> | ||
| <code>{key}</code> | ||
| </td> | ||
| <td>{attribute.type}</td> | ||
| {/* Briefs are long; override the site's nowrap rule for non-last columns. */} | ||
| <td | ||
| style={{whiteSpace: 'normal', minWidth: '300px'}} | ||
| dangerouslySetInnerHTML={{__html: description}} | ||
| /> | ||
| <td> | ||
| {attribute.example !== undefined && ( | ||
| <code>{formatExample(attribute.example)}</code> | ||
| )} | ||
| </td> | ||
| </tr> | ||
| ))} | ||
| </tbody> | ||
| </table> | ||
| ); | ||
| } | ||
|
|
||
| function formatExample(example: AttributeValue) { | ||
| if (typeof example !== 'string') { | ||
| return JSON.stringify(example); | ||
| } | ||
| // Single-quote stringified JSON so its inner double quotes stay readable. | ||
| return /^[[{]/.test(example) ? `'${example}'` : `"${example}"`; | ||
| } | ||
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
Oops, something went wrong.
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.
Paragraph unwrap breaks multi-block briefs
Medium Severity
micromarkoutput is unwrapped by stripping a leading<p>and a trailing</p>independently. That only works for a single paragraph. Multi-paragraphbrieftext, orbriefplusnotesthat form more than one block, leaves mismatched tags inside the cell viadangerouslySetInnerHTML, so later paragraphs pick up prose margins and the description renders inconsistently.Reviewed by Cursor Bugbot for commit 8c164b3. Configure here.