Skip to content

feat(packages): Expose attribute deprecation chains on ATTRIBUTE_METADATA - #508

Merged
Lms24 merged 10 commits into
mainfrom
lms/feat-attribute-read-chains
Aug 13, 2026
Merged

Lms24 merged 10 commits into
mainfrom
lms/feat-attribute-read-chains

Conversation

@Lms24

@Lms24 Lms24 commented Jul 15, 2026 •

Copy link
Copy Markdown
Member

Expose attribute key chains on the ATTRIBUTE_METADATA object under ATTRIBUTE_METADATA[attributeKey].keys.

A chain leads with the stable, non-deprecated key, so reading the chain from any key in the family always prefers the current key regardless of which key the caller uses. Within a chain the order is:

  • the stable attribute, then its search_alias.name and search_alias.deprecated_aliases
  • its non-deprecated aliases, each expanded the same way
  • the deprecated attributes it replaces (alphabetically), each expanded the same way

Only backfill and normalize deprecations are taken into accound. A transform or null deprecation is not part of the chain since it signals a shift in semantics or attribute values.

Potential Usage

@sentry/conventions consumers can make a bundle-size-safe lookup with this like so:

function getAttributeValueForKeys<T = unknown>(attributes: Record<string, unknown>, keys: string[]): T | undefined {
  // first defined attribute wins
  const foundKey = keys.find(k => attributes[k] != null)
  return foundKey ? attributes[foundKey] : undefined
}

const httpMethod = getAttributeValueForKeys(spanJson.attributes, ATTRIBUTE_METADATA['http.method'].keys);

As long as accesses to the metadata object are string literals (as opposed to variables), bundlers can tree-shake out the unused entries. #569 adds a more size-efficient lookup to query across all attributes without having to specify a set of keys.

closes #496

@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Breaking Changes 🛠

  • (ops) Drop category prefix and SPAN_OP suffix from op constants by Lms24 in #565

New Features ✨

Attributes

  • Add http.request.duration by loewenheim in #697
  • Add integrity policy attributes by loewenheim in #691
  • Deprecate legacy MCP tool result fields by betegon in #689
  • Align MCP conventions and OAuth client identity by betegon in #671
  • Add AWS service instrumentation attributes by pabloDeputter in #672
  • Add gen_ai memory conventions by ArthurKnaus in #653
  • Add vercel.ai.telemetry.metadata.<key> attribute by isaacs in #662
  • Add nel.sampling_fraction by loewenheim in #668
  • Add sentry.link.type span link attribute by Lms24 in #656
  • Add internal sentry.is_localhost attribute by Lms24 in #646
  • Add the INP target and interaction type attributes by logaretm in #641
  • Deprecate the web vital report event attributes by logaretm in #642
  • Add React Native native module call attributes by alwx in #564
  • Use the web-vitals navigation types as-is for browser.navigation.type by logaretm in #640
  • Add legacy gen_ai cache token attributes (deprecated) by JPeer264 in #582
  • Add cache.item_age and cache.tags by s1gr1d in #637
  • Add browser.navigation.id by logaretm in #634
  • Replace fs_error in favor of error.type by JPeer264 in #589
  • Complete the gen_ai.tool.definitions alias group by JPeer264 in #595
  • Add sveltekit.* attributes emitted by SvelteKit's native spans by Lms24 in #611
  • Add browser.navigation.type, move navigation.* to router.navigation.* by logaretm in #600
  • Add langchain.chain.name (deprecated) in favor of gen_ai.pipeline.name by RulaKhaled in #599
  • Add browser.paint.type by Lms24 in #606
  • Complete net.* aliases and transform net.transport by JPeer264 in #588
  • Name the replacements for the deprecated http.target by JPeer264 in #587
  • Add url.path.params.<key> (deprecated) in favor of url.path.parameter.<key> by JPeer264 in #586
  • Add graphql.source (deprecated) in favor of graphql.document by JPeer264 in #584
  • Add legacy Vercel AI span attributes (deprecated) by JPeer264 in #583
  • Add legacy AMQP and Redis span attributes (deprecated) by JPeer264 in #581
  • Add HTTP body size and status text attributes by msonnb in #574
  • Add graphql.processing.type by andreiborza in #572
  • Add compact search metadata export by nsdeschenes in #569
  • Add search alias metadata by cleptric in #492
  • Add sentry.event.serialized_meta by mjq in #566
  • Change sentry.description scrubbing policy to manual by Lms24 in #555

Descriptions

  • Add more fine grained function.gcp span description rules by Lms24 in #624
  • Add graphql span description rules by Lms24 in #616
  • Add gen_ai span description inference rules by Lms24 in #578

Docs

  • Move LLM links to the footer by cleptric in #654
  • Add Vercel PR previews by sentry-junior in #651

Names

  • Add span name and description conventions for ui.* ops by Lms24 in #643
  • Add FAAS function span name and description rules by Lms24 in #617
  • Add function span name and description rules by Lms24 in #618
  • Add browser.* span name and description rules by Lms24 in #607
  • Add cache span name rules by Lms24 in #605

Op

  • Add gen_ai.evaluate op by andreiborza in #650
  • Deprecate framework-specific span ops by Lms24 in #622
  • Add span op deprecation support by Lms24 in #621
  • Add ui.resolve span op by Lms24 in #633
  • Add mobile OTA update span operations by antonis in #540
  • Add handler op by msonnb in #554
  • Add router span operation by msonnb in #551

Packages

  • Expose attribute deprecation chains on ATTRIBUTE_METADATA by Lms24 in #508
  • Expose attribute deprecation chains on ATTRIBUTE_METADATA by Lms24 in #508

Other

  • (model) Add metric model by giortzisg in #649
  • (ops) Add MCP ops by msonnb in #558
  • (replays) Define replayId as a deprecated attribute by mjq in #401
  • (search-attributes) Add search attribute names by nsdeschenes in #610
  • (span-names) Add url.domainrule for http.client spans by Lms24 in #575
  • Add enum_values entries to shorten attribute briefs by alexander-alderman-webb in #685

Bug Fixes 🐛

Attributes

  • Apply consistent scrubbing across deprecations by mjq in #692
  • Add search_alias to sentry.link.type attribute by Lms24 in #687
  • Remove any as valid attribute type by Lms24 in #677
  • Remove accidentally merged attribute transformation by Lms24 in #638
  • Set db.query.text scrubbing to auto by loewenheim in #625
  • Add status backfill to deprecated attributes with renamed replacements by Lms24 in #571

Descriptions

  • Define template substitution for array values by s1gr1d in #663
  • Add graphql-enhanced http.client span description template by Lms24 in #613

Docs

  • Render inline code in convention descriptions by sentry-junior in #652
  • Add missing file and test docs building in CI by Lms24 in #568

Names

  • Add gen_ai.function_id and gen_ai.pipeline.name to agent span name templates by RulaKhaled in #593
  • Add missing gen_ai ops to span name rules by Lms24 in #579
  • Include tool name in gen_ai.execute_tool span names by Lms24 in #580
  • Correct graphql span name examples by andreiborza in #573

Other

  • (gen_ai) Map Anthropic tool results to canonical attribute by obostjancic in #660
  • (ops) Add http.client.stream to http.client name and description rules by msonnb in #553
  • Use path.posix.join instead of path.join for Windows compatibility by alexander-alderman-webb in #688
  • Alias server_name to device.name instead of server.address by alexander-alderman-webb in #602
  • Force use of Socket PyPI by sentrivana in #598

Documentation 📚

  • (contributing) Document process for fixing a misnamed attribute by sentry-junior in #673
  • Specify TTL lifetime by s1gr1d in #648

Internal Changes 🔧

Attributes

  • Add in deprecated search aliases for replay id by nsdeschenes in #657
  • Clarify parameter name casing by Lms24 in #632
  • Add search alias for segment name by nsdeschenes in #577

Deps

  • Bump sharp from 0.35.4 to 0.35.5 by dependabot in #683
  • Bump source-map-js from 1.2.1 to 1.2.2 by dependabot in #675
  • Bump smol-toml from 1.8.0 to 1.9.0 by dependabot in #674
  • Bump postcss-selector-parser from 7.1.4 to 7.1.6 by dependabot in #676
  • Bump brace-expansion from 5.0.9 to 5.0.12 by dependabot in #665
  • Bump devalue from 5.9.2 to 5.9.4 by dependabot in #666
  • Bump dompurify from 3.4.13 to 3.4.16 by dependabot in #664
  • Bump devalue from 5.8.1 to 5.9.2 by dependabot in #639
  • Bump smol-toml from 1.6.1 to 1.8.0 by dependabot in #635
  • Bump astro from 7.1.0 to 7.2.8 by dependabot in #628
  • Bump sharp from 0.35.3 to 0.35.4 by dependabot in #630
  • Bump js-yaml from 4.3.1 to 4.3.2 by dependabot in #631
  • Bump svgo from 4.0.2 to 4.1.0 by dependabot in #627
  • Bump browserslist from 4.28.2 to 4.28.8 by dependabot in #614
  • Bump fast-uri from 3.1.5 to 3.1.7 by dependabot in #612
  • Bump dompurify from 3.4.12 to 3.4.13 by dependabot in #559
  • Bump js-yaml from 4.3.0 to 4.3.1 by dependabot in #560

Deps Dev

  • Bump oxfmt to 0.72.0 to pull in patched tinypool by Lms24 in #682
  • Bump vitest from 4.1.9 to 4.1.11 by dependabot in #629

Docs

  • Add link preview meta tags by Lms24 in #667
  • Add Sentry Astro SDK by Lms24 in #563

Names

  • Clarify GraphQL OTel divergence note by andreiborza in #626
  • Add OTel divergence note for graphql span names by Lms24 in #615

Search Metadata

  • Add deprecated field to search metadata by nsdeschenes in #658
  • Add visibility field by nsdeschenes in #597

Other

  • (descriptions) Fix http.client span description example by Lms24 in #603
  • (publish) Stop npm version from rewriting yarn.lock by Lms24 in #678
  • (repo) Update CODEOWNERS to include @giortzisg by Lms24 in #708
  • Deprecate gen_ai.evaluate in favor of new gen_ai.decide by alexander-alderman-webb in #696
  • Add "evaluate" as a well-known value for gen_ai.operation.name by alexander-alderman-webb in #680
  • Deprecate mcp.tool.result.content_count by alexander-alderman-webb in #669
  • Add alexander-alderman-webb to CODEOWNERS by cleptric in #655
  • Limit device.name to mobile devices and alias server_name to server.address by alexander-alderman-webb in #647
  • Broaden server.address brief to also allow hostnames by alexander-alderman-webb in #645
  • Type-check TypeScript sources by Lms24 in #567
  • Unstale yarn.lock by Lms24 in #561

Other

  • release: 0.27.0 by andreiborza in 1eff3470
  • release: 0.26.0 by obostjancic in f9dc3411
  • release: 0.25.0 by nsdeschenes in 52048da2
  • release: 0.24.0 by Lms24 in 456f4f94
  • release: 0.23.0 by Lms24 in cbb53e98
  • release: 0.22.0 by Lms24 in 907e32ae
  • release: 0.21.0 by nsdeschenes in 3640a0ec
  • release: 0.20.0 by Lms24 in 5f08e3bf

🤖 This preview updates automatically when you update the PR.

@Lms24 Lms24 changed the title feat(attributes): Expose canonical attribute read chains feat(packages): Expose canonical attribute read chains Jul 15, 2026
@Lms24

Lms24 commented Jul 21, 2026

Copy link
Copy Markdown
Member Author

bugbot review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 1532a46. Configure here.

@Lms24
Lms24 force-pushed the lms/feat-attribute-read-chains branch from 1532a46 to b91c5b1 Compare July 31, 2026 14:34
@Lms24 Lms24 changed the title feat(packages): Expose canonical attribute read chains feat(packages): Expose attribute deprecation chains and getAttributeValue helper Aug 5, 2026
@Lms24
Lms24 force-pushed the lms/feat-attribute-read-chains branch from b91c5b1 to 82b97dc Compare August 7, 2026 13:36
@Lms24
Lms24 changed the base branch from main to add-new-properties August 7, 2026 13:36
@Lms24
Lms24 force-pushed the add-new-properties branch from 71fe662 to 0d4c3cf Compare August 12, 2026 10:28
Base automatically changed from add-new-properties to main August 12, 2026 10:55
Lms24 and others added 6 commits August 12, 2026 15:13
Generate stable-first key chains in JavaScript and Python so SDKs can
read legacy attributes without importing the full metadata registry.
Add small lookup helpers while preserving tree-shakeable package paths.

Fixes #496
Co-Authored-By: Claude <noreply@anthropic.com>

Co-authored-by: Cursor <cursoragent@cursor.com>
Use a single expression to preserve lookup semantics while reducing the
shipped helper by 13 bytes. Move coverage into a dedicated unit test.

Refs GH-496
Co-Authored-By: Claude <noreply@anthropic.com>

Co-authored-by: Cursor <cursoragent@cursor.com>
Add examples and parameter guidance for the JavaScript and Python helpers.
Generate the Python docstring so regeneration preserves the API documentation.

Refs GH-496
Co-Authored-By: Claude <noreply@anthropic.com>

Co-authored-by: Cursor <cursoragent@cursor.com>
Clean up three pre-existing type errors in the attribute generator:

- Drop the `_isDeprecated` destructure in `writeToJs`, which did not exist
  on the element type and was never read.
- Widen `convertToPythonLiteral` to accept `AttributeValue[]`. The body
  already recursed over arrays, but the `AttributeJson['example']`
  annotation excluded them, so passing `examples` did not type check.
- Guard the first Python example on `firstExample !== undefined` so the
  indexed access narrows, instead of passing a possibly-`undefined` value
  into a parameter that did not accept it.
- Remove the unused `attributesDir` and `attributeFiles` parameters from
  `generateMetadataDict` and update the call site.

Generated output is byte-identical: re-running `yarn generate` produces no
diff in the JavaScript or Python attribute files.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… chains

Attribute key chains previously only linked an attribute to the deprecated
attributes it replaces. A value can also be read under an attribute's Sentry
search names or under one of its aliases, so those keys are now part of the
chain too.

Each chain still leads with the stable, non-deprecated key and is shared by
every member of a family, so a read prefers the current key no matter which
constant the caller imports. Within a chain the order is: the stable attribute
and its search names, then its non-deprecated aliases, then the deprecated
attributes it replaces, each expanded the same way.

Only `backfill` and `normalize` deprecations now join a replacement's chain.
A `transform` deprecation, or one with no status, leaves the value under the
original key, so following it would return a value the caller did not ask for.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Lms24
Lms24 force-pushed the lms/feat-attribute-read-chains branch from 82b97dc to a4853c3 Compare August 12, 2026 15:24
@Lms24 Lms24 changed the title feat(packages): Expose attribute deprecation chains and getAttributeValue helper feat(packages): Expose attribute key chains on ATTRIBUTE_METADATA Aug 12, 2026
@Lms24 Lms24 self-assigned this Aug 12, 2026
@Lms24
Lms24 marked this pull request as ready for review August 12, 2026 15:28
@Lms24
Lms24 requested review from a team, cleptric, mjq and nsdeschenes as code owners August 12, 2026 15:28
Comment thread scripts/generate_attributes.ts

@nsdeschenes nsdeschenes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be worth checking out that Seer review comment just to make sure everything's 🤌

@Lms24

Lms24 commented Aug 12, 2026 •

Copy link
Copy Markdown
Member Author

May be worth checking out that Seer review comment just to make sure everything's

Yup, good point. I still had a bug in the code that would add attributes unidirectionally to keys despite the deprecation status being null or transform. Should be fixed now.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5c0d06d. Configure here.

Comment thread test/generated-attribute-keys.test.ts
Comment thread scripts/generate_attributes.ts
Comment thread scripts/generate_attributes.ts
@Lms24
Lms24 merged commit b350b1e into main Aug 13, 2026
17 checks passed
@Lms24
Lms24 deleted the lms/feat-attribute-read-chains branch August 13, 2026 12:30
@Lms24 Lms24 changed the title feat(packages): Expose attribute key chains on ATTRIBUTE_METADATA feat(packages): Expose attribute deprecation chains on ATTRIBUTE_METADATA Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose deprecation chains from conventions packages

2 participants