Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions sentry-rails/spec/sentry/rails/tracing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@
expect(second_span[:parent_span_id]).to eq(first_span[:span_id])

# this is to make sure we calculate the timestamp in the correct scale (second instead of millisecond)
expect(second_span[:timestamp] - second_span[:start_timestamp]).to be_between(10.0 / 1_000_000, 10.0 / 1000)
# Use more relaxed bounds for JRuby compatibility
min_duration = 10.0 / 1_000_000 # 10 microseconds
max_duration = RUBY_PLATFORM == "java" ? 50.0 / 1000 : 10.0 / 1000 # 50ms for JRuby, 10ms for others
expect(second_span[:timestamp] - second_span[:start_timestamp]).to be_between(min_duration, max_duration)
end

it "records transaction alone" do
Expand Down Expand Up @@ -89,7 +92,10 @@
expect(second_span[:parent_span_id]).to eq(first_span[:span_id])

# this is to make sure we calculate the timestamp in the correct scale (second instead of millisecond)
expect(second_span[:timestamp] - second_span[:start_timestamp]).to be_between(10.0 / 1_000_000, 10.0 / 1000)
# Use more relaxed bounds for JRuby compatibility
min_duration = 10.0 / 1_000_000 # 10 microseconds
max_duration = RUBY_PLATFORM == "java" ? 50.0 / 1000 : 10.0 / 1000 # 50ms for JRuby, 10ms for others
expect(second_span[:timestamp] - second_span[:start_timestamp]).to be_between(min_duration, max_duration)

third_span = transaction[:spans][2]
expect(third_span[:op]).to eq("template.render_template.action_view")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,26 @@ def timecop_delay
# the default queue
let!(:queue) { Sidekiq::Queue.new("default") }

before do
def ensure_queue_empty(queue, timeout: 0.1)
queue.clear
start_time = Time.now
while queue.size > 0 && (Time.now - start_time) < timeout
sleep(0.001)
end
end

before do
ensure_queue_empty(queue)

perform_basic_setup do |config|
config.traces_sample_rate = 1.0
end
end

after do
ensure_queue_empty(queue)
end

it "does not add user to the job if they're absent in the current scope" do
client.push('queue' => 'default', 'class' => HappyWorker, 'args' => [])

Expand Down
Loading