Running this repo requires the usage of volta. See instructions on installing volta on their documentation here. The repo requires Node v22 or higher to run.
To install required dependencies, run yarn install.
yarn installBefore attributes are sent from SDKs, or attribute values or definitions change, the attributes MUST be defined or updated in this repo. If the convention you need doesn't exist yet, open a PR there to propose it. Only after the convention has been merged, ship it in an SDK. This ensures all SDKs use consistent naming and semantics.
The merge process for sentry-conventions PRs:
- Open a PR with the proposed convention change (Adding an Attribute).
- Get an approval from at least one code owner.
- Wait for at least 3 business days after the first approval to give other code owners a chance to review. This grace period exists because attribute names, once shipped in an SDK release, are effectively permanent. If a bad name gets adopted by even one SDK, fixing it requires a deprecation cycle across the SDK(s) that shipped it and the Sentry backend. There is no urgency exception. If a name feels wrong, raise it during review, not after.
- Merge your PR (alternatively, code owners may merge it after review)
Important
Before proposing a new attribute, check the OpenTelemetry semantic conventions registry.
If OTel already defines the attribute:
- Use the OTel name and type. Set
is_in_otel: true. - Do not create a Sentry-specific synonym!. Diverging from OTel for the same concept creates more confusion and work than value.
If OTel doesn't define it, or the concept is Sentry-specific, set is_in_otel: false.
When in doubt, prefer OTel alignment. Sentry conventions should only extend OTel, not diverge from it.
Run yarn run create:attribute to create a new attribute. This will prompt you to enter information about the attribute. There are two modes:
- Interactive mode: This will prompt you to enter information about the attribute.
- Non-interactive mode: This will use the information provided to create the attribute. You'll need to explicitly specify all the needed information when running the command.
# Interactive mode
yarn run create:attribute
# Non-interactive mode
yarn run create:attribute --key http.route --description "The route pattern of the request" --type string --has_pii false --is_in_otel true --example "/users/:id" --alias "url.template"After you've created an attribute, the script will ask if you'd like to generate the docs. This will run yarn run generate. If you want to skip this step, you can run yarn run generate manually afterwards.
If you need help, run yarn run create:attribute --help to see the available options.
Span name conventions are organized loosely by type of span operation. To create a convention for a new type of span operation:
- Create a new file in the
models/namedirectory. Ideally the file name should match a folder in themodels/attributesdirectory (e.g.,ui.json). - Fill in the contents of the file with the necessary information. You can find the schema for the document in
schemas/name.schema.json.
- The
"brief"field should be a short description of what kind of information thenamefield contains for this kind of span operation. - The
"is_in_otel"field describes whether the OpenTelemetry Semantic Conventions describe how thenamefield should be constructed for this kind of span operation. If there are no OTel conventions for this kind of operation, set this field tofalse. - The
"op"field contains a list of all known Sentry span operation names that the convention is applicable to. For example, in Sentry"db", and"db.query"spans can construct their names using the"db"name conventions. - The
"templates"field contains a list of string templates for constructing thenamefield from known span attributes. Strings in curly braces are replaced with the value of the corresponding attribute. For example, the template"{{db.system}}"becomes"postgres"for a span with the attribute"db.system"set to the string"postgres". The top template should be the preferred version, with subsequent templates being fallbacks. The final template should be a static string without any curly braces. - The
"examples"field contains a list of example span names. Please add a few examples that correspond to the available templates.
Remember to run yarn run generate after editing or creating a name convention to recreate the documentation and auto-generated code.
After you edit an attribute or add a new one, run yarn run generate to generate and format the code, which are generated from the json files stored in the model directory.
Docs are generated on every PR merge.
The generated code packages can be published to package repositories (currently npm and pypi) at any time by creating a new release:
- Trigger the Release Github workflow. Define the version to be released. Usually, assuming any attribute changes are part of the release, that's a new minor version. We're intentionally on major version
0.xto allow breaking changes in minor releases for now. - Head over to
getsentry/publishand wait for a new issue to appear. Ensure the changes look correct and all CI checks have passed - Add the
acceptlabel. A bot will start the release workflow. Wait for the release to complete.
Here's a list of policies that any newly added attributes MUST follow. Most of these are automatically enforced by the test suite.
- The attribute MUST be namespaced. Example:
nextjs.function_id, notfunction_id. - Use dots as separators for namespaces and logical grouoing, not underscores (
http.request.method, nothttp_request_method) - Use
snake_casefor multi-word names (browser.web_vital.ttfb.request_time, notbrowser.webVital.ttfb.request-time) - Namespace first (
db.system, notsystem.db) - The
piifield in the attribute definition MUST bemaybeortrue(if the attribute can contain sensitive data). It SHOULD befalseonly if scrubbing the attribute value for PII would potentially break product features. For example,sentry.replay_idshould havepiiset tofalse. - When an attribute is added that deprecates an old one:
- The old one should be marked as deprecated, and it MUST point to the new one using the
deprecation.replacementfield. - For both the new and the old attribute, and any existing aliases of the old attribute, the new and old names MUST be added to the
aliaseslist. - The deprecation status of the old one SHOULD be set to
backfillfor at least 90 days, and then set tonormalize.
- The old one should be marked as deprecated, and it MUST point to the new one using the
- Prefer keeping names stable. Renames require deprecation cycles across all SDKs that adopted the attribute!
This repo uses Vitest for testing. To run the tests, run yarn test.
The tests enforce logical correctness as well as policies that the model should follow.
yarn testThis repo uses Biome and other platform-specific tools for linting. To run the linting, run yarn lint.
yarn lint