Skip to content

Conversation

saviogl
Copy link

@saviogl saviogl commented Aug 25, 2025

Sentry's OpenTelemetry (OTel) adapter does not do the greatest job in adapting the OTel span to a semantically correct sentry span, nor does it expose the OTel span in the context for sampling decisions. This PR adds a OTel span as an additional custom sampling context so it can be used for sampling decisions. This gives clients more opportunities to use the entire context of the OTel span for sampling decisions, and allows replicating sampling mechanisms as originally suggested by the Sentry team via the "Sampling Function".

https://docs.sentry.io/platforms/ruby/configuration/sampling/#setting-a-sampling-function

Thanks for your Pull Request 🎉

Please keep these instructions in mind so we can review it more efficiently:

  • Add the references of all the related issues/PRs in the description
  • Whether it's a new feature or a bug fix, make sure they're covered by new test cases
  • If this PR contains any refactoring work, please give it its own commit(s)
  • Finally, please add an entry to the corresponding changelog

Other Notes

  • We squash all commits before merging
  • We generally review new PRs within a week
  • If you have any question, you can ask for feedback in our discord community first

closes #2684
closes RUBY-86

cursor[bot]

This comment was marked as outdated.

Copy link
Collaborator

@solnic solnic left a comment

Choose a reason for hiding this comment

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

Thanks for the PR - please rebase this first which should fix the build 😄

Sentry's opentelemetry adapter does not do the greatest job in
adapting the opentelemetry span to a semantically correct sentry span,
nor does it expose the opentelemetry span in the context for sampling
decisions. This PR adds a opentelemetry span as an additional custom sampling
context so it can be used for sampling decisions. This gives clients more
opportunity to use the entire context of the opentelemetry span for sampling
decisions, and allows replicating sampling mechanisms as orignally suggested
by the Sentry team via the "Sampling Function".

https://docs.sentry.io/platforms/ruby/configuration/sampling/#setting-a-sampling-function
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 OpenTelemetry span as additional sampling context
2 participants