Skip to content

feat(metrics): Add trace metric enrichment with default and user attributes (RUST-169)#1031

Draft
szokeasaurusrex wants to merge 2 commits intoszokeasaurusrex/core-metrics-capturefrom
szokeasaurusrex/metrics-defaults
Draft

feat(metrics): Add trace metric enrichment with default and user attributes (RUST-169)#1031
szokeasaurusrex wants to merge 2 commits intoszokeasaurusrex/core-metrics-capturefrom
szokeasaurusrex/metrics-defaults

Conversation

@szokeasaurusrex
Copy link
Member

Add metric enrichment in sentry-core so emitted trace metrics include:

  • Trace/span association: trace_id from active span or propagation
    context, span_id from active span when not explicitly set.
  • Default SDK attributes: sentry.environment, sentry.release,
    sentry.sdk.name, sentry.sdk.version, and server.address.
  • User PII attributes (user.id, user.name, user.email) gated by
    send_default_pii.
  • before_send_metric callback for filtering/modifying metrics.

Attribute merges use or_insert to preserve explicitly set metric
attributes, matching the behavior specified in
https://develop.sentry.dev/sdk/telemetry/metrics/#default-attributes
and https://develop.sentry.dev/sdk/telemetry/metrics/#user-attributes.

Scope and client enrichment logic is based on the approach from #997.

Co-authored-by: Joris Bayer joris.bayer@sentry.io

Closes #1024
Closes RUST-169

…ibutes (RUST-169)

Add metric enrichment in sentry-core so emitted trace metrics include:

- Trace/span association: trace_id from active span or propagation
  context, span_id from active span when not explicitly set.
- Default SDK attributes: sentry.environment, sentry.release,
  sentry.sdk.name, sentry.sdk.version, and server.address.
- User PII attributes (user.id, user.name, user.email) gated by
  send_default_pii.
- before_send_metric callback for filtering/modifying metrics.

Attribute merges use or_insert to preserve explicitly set metric
attributes, matching the behavior specified in
https://develop.sentry.dev/sdk/telemetry/metrics/#default-attributes
and https://develop.sentry.dev/sdk/telemetry/metrics/#user-attributes.

Scope and client enrichment logic is based on the approach from #997.

Co-authored-by: Joris Bayer <joris.bayer@sentry.io>

Closes #1024
Closes [RUST-169](https://linear.app/getsentry/issue/RUST-169/add-trace-metric-default-and-user-attribute-enrichment-in-sentry-core)
@linear-code
Copy link

linear-code bot commented Mar 9, 2026

@github-actions
Copy link

github-actions bot commented Mar 9, 2026

Fails
🚫 Please consider adding a changelog entry for the next release.
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Features

- Add trace metric enrichment with default and user attributes (RUST-169) ([#1031](https://github.com/getsentry/sentry-rust/pull/1031))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against a2f7297

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.

1 participant