File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
sentry-rails/spec/sentry/rails
sentry-sidekiq/spec/sentry/sidekiq Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 5353 expect ( second_span [ :parent_span_id ] ) . to eq ( first_span [ :span_id ] )
5454
5555 # this is to make sure we calculate the timestamp in the correct scale (second instead of millisecond)
56- expect ( second_span [ :timestamp ] - second_span [ :start_timestamp ] ) . to be_between ( 10.0 / 1_000_000 , 10.0 / 1000 )
56+ # Use more relaxed bounds for JRuby compatibility
57+ min_duration = 10.0 / 1_000_000 # 10 microseconds
58+ max_duration = RUBY_PLATFORM == "java" ? 50.0 / 1000 : 10.0 / 1000 # 50ms for JRuby, 10ms for others
59+ expect ( second_span [ :timestamp ] - second_span [ :start_timestamp ] ) . to be_between ( min_duration , max_duration )
5760 end
5861
5962 it "records transaction alone" do
8992 expect ( second_span [ :parent_span_id ] ) . to eq ( first_span [ :span_id ] )
9093
9194 # this is to make sure we calculate the timestamp in the correct scale (second instead of millisecond)
92- expect ( second_span [ :timestamp ] - second_span [ :start_timestamp ] ) . to be_between ( 10.0 / 1_000_000 , 10.0 / 1000 )
95+ # Use more relaxed bounds for JRuby compatibility
96+ min_duration = 10.0 / 1_000_000 # 10 microseconds
97+ max_duration = RUBY_PLATFORM == "java" ? 50.0 / 1000 : 10.0 / 1000 # 50ms for JRuby, 10ms for others
98+ expect ( second_span [ :timestamp ] - second_span [ :start_timestamp ] ) . to be_between ( min_duration , max_duration )
9399
94100 third_span = transaction [ :spans ] [ 2 ]
95101 expect ( third_span [ :op ] ) . to eq ( "template.render_template.action_view" )
Original file line number Diff line number Diff line change @@ -141,13 +141,26 @@ def timecop_delay
141141 # the default queue
142142 let! ( :queue ) { Sidekiq ::Queue . new ( "default" ) }
143143
144- before do
144+ def ensure_queue_empty ( queue , timeout : 0.1 )
145145 queue . clear
146+ start_time = Time . now
147+ while queue . size > 0 && ( Time . now - start_time ) < timeout
148+ sleep ( 0.001 )
149+ end
150+ end
151+
152+ before do
153+ ensure_queue_empty ( queue )
154+
146155 perform_basic_setup do |config |
147156 config . traces_sample_rate = 1.0
148157 end
149158 end
150159
160+ after do
161+ ensure_queue_empty ( queue )
162+ end
163+
151164 it "does not add user to the job if they're absent in the current scope" do
152165 client . push ( 'queue' => 'default' , 'class' => HappyWorker , 'args' => [ ] )
153166
You can’t perform that action at this time.
0 commit comments