|
41 | 41 | expect(propagation_context.sample_rand).to eq(expected) |
42 | 42 | end |
43 | 43 |
|
44 | | - it "properly handles sampling decisions" do |
45 | | - test_cases = [ |
46 | | - { sample_rand: 0.1, sample_rate: 0.5, should_sample: true }, |
47 | | - { sample_rand: 0.7, sample_rate: 0.5, should_sample: false }, |
48 | | - { sample_rand: 0.5, sample_rate: 0.5, should_sample: false }, |
49 | | - { sample_rand: 0.499999, sample_rate: 0.5, should_sample: true } |
50 | | - ] |
51 | | - |
52 | | - test_cases.each do |test_case| |
53 | | - Sentry.configuration.traces_sample_rate = test_case[:sample_rate] |
| 44 | + [ |
| 45 | + { sample_rand: 0.1, sample_rate: 0.5, should_sample: true }, |
| 46 | + { sample_rand: 0.7, sample_rate: 0.5, should_sample: false }, |
| 47 | + { sample_rand: 0.5, sample_rate: 0.5, should_sample: false }, |
| 48 | + { sample_rand: 0.499999, sample_rate: 0.5, should_sample: true } |
| 49 | + ].each do |test_case| |
| 50 | + it "with #{test_case.inspect} - properly handles sampling decisions" do |
| 51 | + Sentry.configuration.traces_sample_rate = test_case[:sample_rate] |
54 | 52 |
|
55 | | - env = { |
56 | | - "HTTP_SENTRY_TRACE" => "771a43a4192642f0b136d5159a501700-7c51afd529da4a2a-", |
57 | | - "HTTP_BAGGAGE" => "sentry-trace_id=771a43a4192642f0b136d5159a501700,sentry-sample_rand=#{test_case[:sample_rand]}" |
58 | | - } |
| 53 | + env = { |
| 54 | + "HTTP_SENTRY_TRACE" => "771a43a4192642f0b136d5159a501700-7c51afd529da4a2a-", |
| 55 | + "HTTP_BAGGAGE" => "sentry-trace_id=771a43a4192642f0b136d5159a501700,sentry-sample_rand=#{test_case[:sample_rand]}" |
| 56 | + } |
59 | 57 |
|
60 | | - transaction = Sentry.continue_trace(env, name: "test") |
61 | | - Sentry.start_transaction(transaction: transaction) |
| 58 | + transaction = Sentry.continue_trace(env, name: "test") |
| 59 | + Sentry.start_transaction(transaction: transaction) |
62 | 60 |
|
63 | | - expect(transaction.sampled).to eq(test_case[:should_sample]) |
64 | | - end |
| 61 | + expect(transaction.sampled).to eq(test_case[:should_sample]) |
65 | 62 | end |
| 63 | + end |
66 | 64 |
|
67 | 65 | it "ensures baggage propagation includes correct sample_rand" do |
68 | 66 | env = { |
|
0 commit comments