File tree Expand file tree Collapse file tree 4 files changed +35
-5
lines changed
Expand file tree Collapse file tree 4 files changed +35
-5
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,11 @@ The SDK now records a new `net.http` breadcrumb whenever the user makes a reques
1818
1919<img width =" 869 " alt =" net http breadcrumb " src =" https://user-images.githubusercontent.com/5079556/114298326-5f7c3d80-9ae8-11eb-9108-222384a7f1a2.png " >
2020
21+ - Add the third tracing state [ #1402 ] ( https://github.com/getsentry/sentry-ruby/pull/1402 )
22+ - ` rate == 0 ` - Tracing enabled. Rejects all locally created transactions but respects sentry-trace.
23+ - ` 1 > rate > 0 ` - Tracing enabled. Samples locally created transactions with the rate and respects sentry-trace.
24+ - ` rate < 0 ` or ` rate > 1 ` - Tracine disabled.
25+
2126### Refactorings
2227
2328- Let Transaction constructor take an optional hub argument [ #1384 ] ( https://github.com/getsentry/sentry-ruby/pull/1384 )
Original file line number Diff line number Diff line change @@ -288,7 +288,7 @@ def enabled_in_current_env?
288288 end
289289
290290 def tracing_enabled?
291- !!( ( @traces_sample_rate && @traces_sample_rate > 0 .0) || @traces_sampler )
291+ !!( ( @traces_sample_rate && @traces_sample_rate >= 0.0 && @traces_sample_rate <= 1 .0) || @traces_sampler )
292292 end
293293
294294 def stacktrace_builder
Original file line number Diff line number Diff line change 66 expect ( subject . tracing_enabled? ) . to eq ( false )
77 end
88
9- context "when traces_sample_rate == 0 .0" do
9+ context "when traces_sample_rate > 1 .0" do
1010 it "returns false" do
11- subject . traces_sample_rate = 0
11+ subject . traces_sample_rate = 1.1
1212
1313 expect ( subject . tracing_enabled? ) . to eq ( false )
1414 end
1515 end
1616
17+ context "when traces_sample_rate == 0.0" do
18+ it "returns true" do
19+ subject . traces_sample_rate = 0
20+
21+ expect ( subject . tracing_enabled? ) . to eq ( true )
22+ end
23+ end
24+
1725 context "when traces_sample_rate > 0" do
1826 it "returns true" do
1927 subject . traces_sample_rate = 0.1
Original file line number Diff line number Diff line change 2424 Sentry . configuration
2525 end
2626
27- context "when tracing is enabled" do
27+ context "when tracing is enabled (> 0) " do
2828 before do
2929 configuration . traces_sample_rate = 1.0
3030 end
4747 end
4848 end
4949
50- context "when tracing is disabled " do
50+ context "when tracing is enabled (= 0) " do
5151 before do
5252 configuration . traces_sample_rate = 0.0
5353 end
5454
55+ it "returns correctly-formatted value" do
56+ child_transaction = described_class . from_sentry_trace ( sentry_trace , op : "child" )
57+
58+ expect ( child_transaction . trace_id ) . to eq ( subject . trace_id )
59+ expect ( child_transaction . parent_span_id ) . to eq ( subject . span_id )
60+ expect ( child_transaction . parent_sampled ) . to eq ( true )
61+ # doesn't set the sampled value
62+ expect ( child_transaction . sampled ) . to eq ( nil )
63+ expect ( child_transaction . op ) . to eq ( "child" )
64+ end
65+ end
66+
67+ context "when tracing is disabled" do
68+ before do
69+ configuration . traces_sample_rate = false
70+ end
71+
5572 it "returns nil" do
5673 expect ( described_class . from_sentry_trace ( sentry_trace , op : "child" ) ) . to be_nil
5774 end
You can’t perform that action at this time.
0 commit comments