Skip to content

Commit

Permalink
Remove unnecessary sucker_punch mutexes.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahchen6 committed Feb 6, 2025
1 parent 98e5299 commit 1dff58c
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions spec/datadog/tracing/contrib/sucker_punch/patcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
end

let(:expect_thread?) { true }
let(:mutex) { Mutex.new }

let(:worker_class) do
Class.new do
Expand All @@ -51,12 +50,6 @@ def perform(action = :none, **_)
end
end

def check_spans_count_eq(count)
mutex.synchronize do
try_wait_until { get_spans_count == count }
end
end

context 'successful job' do
subject(:dummy_worker_success) { worker_class.perform_async }

Expand All @@ -67,19 +60,19 @@ def check_spans_count_eq(count)
it_behaves_like 'measured span for integration', true do
before do
dummy_worker_success
check_spans_count_eq(2)
try_wait_until { get_spans_count == 2 }
end
end

it 'generates two spans, one for pushing to enqueue and one for the job itself' do
is_expected.to be true
check_spans_count_eq(2)
try_wait_until { get_spans_count == 2 }
expect(spans.length).to eq(2)
end

it 'instruments successful job' do
is_expected.to be true
check_spans_count_eq(2)
try_wait_until { get_spans_count == 2 }

expect(job_span.service).to eq(tracer.default_service)
expect(job_span.name).to eq('sucker_punch.perform')
Expand All @@ -92,7 +85,7 @@ def check_spans_count_eq(count)

it 'instruments successful enqueuing' do
is_expected.to be true
check_spans_count_eq(2)
try_wait_until { get_spans_count == 2 }

expect(enqueue_span.service).to eq(tracer.default_service)
expect(enqueue_span.name).to eq('sucker_punch.perform_async')
Expand All @@ -113,13 +106,13 @@ def check_spans_count_eq(count)
it_behaves_like 'measured span for integration', true do
before do
dummy_worker_fail
check_spans_count_eq(2)
try_wait_until { get_spans_count == 2 }
end
end

it 'instruments a failed job' do
is_expected.to be true
check_spans_count_eq(2)
try_wait_until { get_spans_count == 2 }

expect(job_span.service).to eq(tracer.default_service)
expect(job_span.name).to eq('sucker_punch.perform')
Expand All @@ -140,13 +133,13 @@ def check_spans_count_eq(count)
it_behaves_like 'measured span for integration', true do
before do
dummy_worker_delay
check_spans_count_eq(2)
try_wait_until { get_spans_count == 2 }
end
end

it 'instruments enqueuing for a delayed job' do
dummy_worker_delay
check_spans_count_eq(2)
try_wait_until { get_spans_count == 2 }

expect(enqueue_span.service).to eq(tracer.default_service)
expect(enqueue_span.name).to eq('sucker_punch.perform_in')
Expand Down

0 comments on commit 1dff58c

Please sign in to comment.