Skip to content

Conversation

@saviogl
Copy link
Contributor

@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
@solnic solnic merged commit b6f9dce into getsentry:master Nov 25, 2025
137 of 138 checks passed
@codecov
Copy link

codecov bot commented Nov 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.33%. Comparing base (611ef73) to head (7c8ab68).
⚠️ Report is 43 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2683      +/-   ##
==========================================
+ Coverage   97.31%   97.33%   +0.01%     
==========================================
  Files         144      144              
  Lines        5657     5657              
==========================================
+ Hits         5505     5506       +1     
+ Misses        152      151       -1     
Components Coverage Δ
sentry-ruby 97.78% <ø> (ø)
sentry-rails 95.72% <ø> (+0.10%) ⬆️
sentry-sidekiq 96.57% <ø> (ø)
sentry-resque 94.44% <ø> (ø)
sentry-delayed_job 94.68% <ø> (ø)
sentry-opentelemetry 99.31% <ø> (ø)
Files with missing lines Coverage Δ
...lemetry/lib/sentry/opentelemetry/span_processor.rb 100.00% <ø> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@solnic solnic mentioned this pull request Nov 25, 2025
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