Skip to content

Propagated sampling rates #2671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Propagated sampling rates #2671

wants to merge 8 commits into from

Conversation

solnic
Copy link
Collaborator

@solnic solnic commented Jul 31, 2025

This ensures that we follow the spec as described here https://develop.sentry.dev/sdk/telemetry/traces/#propagated-random-value

@solnic solnic force-pushed the propagated-sampling-rates branch 3 times, most recently from fa9fe50 to e1b1e74 Compare August 11, 2025 09:46
@solnic solnic force-pushed the propagated-sampling-rates branch from e1b1e74 to e8da627 Compare August 12, 2025 15:18
@solnic solnic marked this pull request as ready for review August 12, 2025 15:18
@solnic solnic requested a review from sl0thentr0py August 12, 2025 15:19
@solnic solnic force-pushed the propagated-sampling-rates branch from e8da627 to 206704f Compare August 12, 2025 15:22
cursor[bot]

This comment was marked as outdated.

@solnic solnic force-pushed the propagated-sampling-rates branch 6 times, most recently from f054365 to c720d30 Compare August 13, 2025 09:55
cursor[bot]

This comment was marked as outdated.

@solnic solnic force-pushed the propagated-sampling-rates branch from c720d30 to 3581ae9 Compare August 13, 2025 10:08
cursor[bot]

This comment was marked as outdated.

@solnic solnic force-pushed the propagated-sampling-rates branch from 3581ae9 to 0fdbceb Compare August 13, 2025 11:36
cursor[bot]

This comment was marked as outdated.

@solnic solnic force-pushed the propagated-sampling-rates branch from 2706368 to 763c8ad Compare August 13, 2025 13:42
@getsentry getsentry deleted a comment from codecov bot Aug 14, 2025
Copy link

codecov bot commented Aug 14, 2025

Codecov Report

❌ Patch coverage is 98.98990% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.42%. Comparing base (9b37693) to head (04fe927).

Files with missing lines Patch % Lines
sentry-ruby/lib/sentry/utils/sample_rand.rb 98.11% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2671   +/-   ##
=======================================
  Coverage   97.41%   97.42%           
=======================================
  Files         135      136    +1     
  Lines        5229     5326   +97     
=======================================
+ Hits         5094     5189   +95     
- Misses        135      137    +2     
Components Coverage Δ
sentry-ruby 97.77% <98.98%> (+0.02%) ⬆️
sentry-rails 95.95% <ø> (-0.15%) ⬇️
sentry-sidekiq 96.57% <ø> (ø)
sentry-resque 94.44% <ø> (ø)
sentry-delayed_job 94.68% <ø> (ø)
sentry-opentelemetry 99.31% <ø> (ø)
Files with missing lines Coverage Δ
sentry-ruby/lib/sentry-ruby.rb 99.14% <100.00%> (+<0.01%) ⬆️
sentry-ruby/lib/sentry/hub.rb 97.93% <ø> (ø)
sentry-ruby/lib/sentry/propagation_context.rb 97.40% <100.00%> (+0.91%) ⬆️
sentry-ruby/lib/sentry/transaction.rb 98.32% <100.00%> (+0.24%) ⬆️
sentry-ruby/lib/sentry/utils/sample_rand.rb 98.11% <98.11%> (ø)

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

Copy link
Member

@sl0thentr0py sl0thentr0py left a comment

Choose a reason for hiding this comment

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

logic looks perfect, nice work!

if we can avoid deduplication it would be great, but maybe I missed a reason why transaction needs its own logic. We will remove Transaction.from_sentry_trace completely in the major either way.

@@ -139,6 +154,29 @@ def self.extract_sentry_trace(sentry_trace)
PropagationContext.extract_sentry_trace(sentry_trace)
end

def self.extract_sample_rand_from_baggage(baggage, trace_id, parent_sampled)
Copy link
Member

Choose a reason for hiding this comment

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

can we not define these methods again, but add params to the ones in PropagationContext and reuse them?

so expose

  • PropagationContext.extract_sample_rand_from_baggage(baggage)
  • PropgationContext.generate_sample_rand(baggage, trace_id, parent_sampled)

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