File tree Expand file tree Collapse file tree
sentry-ruby/spec/sentry/transactions Expand file tree Collapse file tree Original file line number Diff line number Diff line change 117117 expect ( transaction . trace_id ) . to eq ( request [ :trace_id ] )
118118 end
119119 end
120+
121+ it "handles corrupted trace context during transaction creation" do
122+ # TODO: does it make sense to even handle such case?
123+ transaction = Sentry ::Transaction . new (
124+ hub : Sentry . get_current_hub ,
125+ trace_id : nil ,
126+ name : "corrupted_trace_test" ,
127+ op : "test"
128+ )
129+
130+ expect ( transaction . sample_rand ) . to be_a ( Float )
131+ expect ( transaction . sample_rand ) . to be >= 0.0
132+ expect ( transaction . sample_rand ) . to be < 1.0
133+ expect ( Sentry ::Utils ::SampleRand . valid? ( transaction . sample_rand ) ) . to be true
134+
135+ Sentry . start_transaction ( transaction : transaction )
136+ expect ( [ true , false ] ) . to include ( transaction . sampled )
137+
138+ baggage = transaction . get_baggage
139+ expect ( baggage . items [ "sample_rand" ] ) . to match ( /\A \d +\. \d {6}\z / )
140+ end
120141 end
121142end
You can’t perform that action at this time.
0 commit comments