Skip to content

Commit 04fe927

Browse files
committed
More tests
1 parent 763c8ad commit 04fe927

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

sentry-ruby/spec/sentry/transactions/sample_rand_propagation_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,26 @@
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
121142
end

0 commit comments

Comments
 (0)