Skip to content

feat(otel): write OTel environment into sentry.environment#196

Merged
mjq merged 4 commits into
mainfrom
mjq/environment-rename
Nov 25, 2025
Merged

feat(otel): write OTel environment into sentry.environment#196
mjq merged 4 commits into
mainfrom
mjq/environment-rename

Conversation

@mjq

@mjq mjq commented Nov 21, 2025

Copy link
Copy Markdown
Member

Description

By convention, OTel SDKs sends environment name in the deployment.environment.name resource attribute (spec).

We would like Sentry's environment filters to work with OTel data. This PR attempts to use sentry-conventions' backfilling to accomplish this, writing the incoming data to our own conventional sentry.environment attribute.

During ingestion, resource attributes are flattened into our single attributes hash with the keys prefixed with resource., so during Relay's processing pipeline, the full attribute name of the source attribute resource.deployment.environment.name. That is the attribute name defined in this PR.

Mechanically this is exactly what I want, but semantically it feels a little weird. Comments below.

Related to DAIN-1099.

PR Checklist

  • I have run yarn test and verified that the tests pass.
  • I have run yarn generate && yarn format to generate and format code and docs.

If an attribute was added:

  • The attribute is in a namespace (e.g. nextjs.function_id, not function_id)
  • I have used the correct value for pii (i.e. maybe or true. Use false only for values that should never be scrubbed such as IDs)

If an attribute was deprecated:

@linear

linear Bot commented Nov 21, 2025

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Nov 21, 2025

Copy link
Copy Markdown
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 4ea051a

@mjq
mjq force-pushed the mjq/environment-rename branch from 3cd14b0 to ecee521 Compare November 21, 2025 01:47
"pii": {
"key": "false"
},
"is_in_otel": true,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

resource.deployment.environment.name isn't in OTel per se, but deployment.environment.name does exist as a resource attribute. 😕

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.

We can probably treat resource.X attributes as a special case. Maybe worth leaving a note about this in the README.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Annoyingly, we already have a resource.X attribute that has nothing to do with OTel resources. Still, I tried adding a note to the readme.

"deprecation": {
"_status": "backfill",
"replacement": "sentry.environment"
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This attribute isn't really deprecated - we've never used it - we just want the backfill (double-write) behaviour.

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.

Maybe instead of deprecation we introduce a new field for this. I don't want to block this PR though, so we can maybe add a note to the brief and create a follow up issue.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Makes sense, but I'd prefer to tackle separately from this PR.

@AbhiPrasad AbhiPrasad 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.

approving to unblock, but lets make sure we get the follow ups in as well

Comment thread README.md Outdated
Co-authored-by: Abhijeet Prasad <[email protected]>
@mjq
mjq merged commit 8d771c2 into main Nov 25, 2025
10 checks passed
@mjq
mjq deleted the mjq/environment-rename branch November 25, 2025 16:50
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.

2 participants