Skip to content

Fix sampling decision precedence#1335

Merged
st0012 merged 4 commits intomasterfrom
fix-transaction-sampling
Apr 2, 2021
Merged

Fix sampling decision precedence#1335
st0012 merged 4 commits intomasterfrom
fix-transaction-sampling

Conversation

@st0012
Copy link
Copy Markdown
Contributor

@st0012 st0012 commented Mar 13, 2021

  1. When traces_sampler is set, the sentry-trace's sampling decision should be put into sampling context to let the user make explicit decision. Currently it forces the transaction to be sampled, which is wrong.
  2. The value of traces_sample_rate should have a lower priority than the traces_sampler and the value of parent_sampled.

@st0012 st0012 added this to the 4.4.0 milestone Mar 13, 2021
@st0012 st0012 requested a review from lobsterkatie March 13, 2021 10:39
@st0012 st0012 self-assigned this Mar 13, 2021
@st0012 st0012 force-pushed the fix-transaction-sampling branch from 434d5ab to f07cf86 Compare March 23, 2021 01:33
Copy link
Copy Markdown
Member

@lobsterkatie lobsterkatie left a comment

Choose a reason for hiding this comment

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

Overall looks good.

There are a few tests I think we should add, to show that precedence is working:

  • "when traces_sampler is provided" context:
    • it "prioritizes traces_sampler over traces_sample_rate", where the sampler always says yes and the rate is 0, and/or the sampler always says no and the rate is 1
    • it "prioritizes traces_sampler over inherited decision" (similar idea)
  • "when traces_sampler is not set" context:
    • it "prioritizes inherited decision over traces_sample_rate" (again, similar idea)

@st0012 st0012 force-pushed the fix-transaction-sampling branch 2 times, most recently from 2fb6e03 to fce5fe9 Compare March 25, 2021 08:03
@st0012 st0012 modified the milestones: 4.4.0, sentry-ruby-4.3.2 Mar 25, 2021
@st0012 st0012 requested a review from lobsterkatie March 25, 2021 08:16
@codecov-io
Copy link
Copy Markdown

codecov-io commented Mar 25, 2021

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.70%. Comparing base (c98d45e) to head (a6ca584).
⚠️ Report is 910 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1335      +/-   ##
==========================================
+ Coverage   98.08%   98.70%   +0.61%     
==========================================
  Files         208      113      -95     
  Lines        9176     5386    -3790     
==========================================
- Hits         9000     5316    -3684     
+ Misses        176       70     -106     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@st0012
Copy link
Copy Markdown
Contributor Author

st0012 commented Mar 25, 2021

@lobsterkatie I also added another commit to correct sampling_context's creation.

@st0012 st0012 force-pushed the fix-transaction-sampling branch from 87eb67a to d01ae1b Compare March 26, 2021 10:22
st0012 added 3 commits March 31, 2021 16:29
1. When traces_sampler is set, the sentry-trace's sampling decision
  should be put into sampling context to let user make explicit
  decision. Currently it forces the transaction to be sampled, which is
  wrong.
2. The value of traces_sample_rate should have a lower priority than the
   traces_sampler and the value of parent_sampled.
When calling this method, a sampling_context should always be provided.
And in most cases, the sampling_context should be assembled in
Hub#start_transaction.
@st0012 st0012 force-pushed the fix-transaction-sampling branch from d01ae1b to 06e62dc Compare March 31, 2021 08:30
@st0012 st0012 merged commit 5adaa73 into master Apr 2, 2021
@st0012 st0012 deleted the fix-transaction-sampling branch April 2, 2021 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants