Skip to content

feat(search-attributes): Add search attribute names - #610

Open
nsdeschenes wants to merge 7 commits into
mainfrom
nd/feat-add-search-attribute-names
Open

feat(search-attributes): Add search attribute names#610
nsdeschenes wants to merge 7 commits into
mainfrom
nd/feat-add-search-attribute-names

Conversation

@nsdeschenes

@nsdeschenes nsdeschenes commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Description

Generate typed SEARCH_* constants for Sentry search names so consumers can avoid hardcoded strings, and publish the search-specific API from its own module:

import {
  ATTRIBUTE_SEARCH_METADATA,
  SEARCH_TRANSACTION,
  type AttributeSearchName,
} from '@sentry/conventions/attributes/search';

What changed

  • Generate search constants, AttributeSearchName, search metadata types, and ATTRIBUTE_SEARCH_METADATA into a dedicated search.ts file instead of attributes.ts.
  • Add the @sentry/conventions/attributes/search package export, build entry, and compatibility shims for older bundlers and TypeScript resolvers.
  • Keep preferred search aliases as the current constants, such as SEARCH_TRANSACTION = 'transaction'.
  • Continue emitting deprecated search names derived from attribute chains, marking them deprecated in favor of the preferred search alias where applicable.
  • Keep current constants for attributes without an explicit search alias.
  • Normalize away a leading sentry. in generated search names, so sentry.transaction and transaction produce only SEARCH_TRANSACTION = 'transaction'.
  • Preserve actual storage keys in canonicalName and deprecationChain metadata without exposing duplicate _SEARCH_* constants.
  • Preserve underscore distinctions so names such as ai.model_id and ai.model.id cannot collide.
  • Keep ATTRIBUTE_SEARCH_METADATA keyed by search_alias.name ?? attribute.key.

Test plan

  • yarn test:js — 9,224 tests pass
  • yarn lint:types:js
  • yarn lint:js
  • yarn build:js
  • Verified a runtime import from @sentry/conventions/attributes/search

nsdeschenes and others added 2 commits September 2, 2026 07:53
Emit typed search name constants from aliases, leftover keys, and
deprecation-chain names so consumers do not hardcode search strings.

Co-authored-by: Cursor <cursoragent@cursor.com>
Regenerate the JS package so search name constants and AttributeSearchName
are available to consumers.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

github-actions Bot commented Sep 2, 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).


New Features ✨

Attributes

  • 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

Names

  • Add browser.* span name and description rules by Lms24 in #607
  • Add cache span name rules by Lms24 in #605

Other

  • (search-attributes) Add search attribute names by nsdeschenes in #610

Internal Changes 🔧

  • (descriptions) Fix http.client span description example by Lms24 in #603

🤖 This preview updates automatically when you update the PR.

@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 e8e14cb. Configure here.

Comment thread scripts/generate_attributes.ts
Comment thread javascript/sentry-conventions/src/attributes.ts Outdated
@nsdeschenes
nsdeschenes marked this pull request as ready for review September 2, 2026 11:34
@nsdeschenes
nsdeschenes requested review from a team, cleptric and mjq as code owners September 2, 2026 11:34
Comment thread scripts/generate_attributes.ts
Comment on lines +489 to +490
.replaceAll('_', '__')
.replaceAll('.', '_')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So this is pretty pedantic but could we consider flipping these?

Suggested change
.replaceAll('_', '__')
.replaceAll('.', '_')
.replaceAll('_', '_')
.replaceAll('.', '__')

. separates a level, and _ separates a multi-word name inside that level. So . is a "heavier" split than _. I think the constants read better if names stay closer together - so e.g. keep "step functions" together as SEARCH_AWS__STEP_FUNCTIONS__ACTIVITY__ARN instead of SEARCH_AWS_STEP__FUNCTIONS_ACTIVITY_ARN.

FWIW this also would make it align with Relay.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me!


function stripSentrySearchPrefix(searchKey: string): string {
const prefix = 'sentry.';
return searchKey.startsWith(prefix) ? searchKey.slice(prefix.length) : searchKey;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

TBH I think I'd rather handle these by putting search aliases on the attributes instead of a blanket policy here - having this enforced by the code generator feels like the wrong place compared to the model JSON 👀

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.

3 participants