@@ -50,6 +50,10 @@ def perform(action = :none, **_)
5050 end
5151 end
5252
53+ def get_spans_count ( tracer = self . tracer )
54+ fetch_traces ( tracer ) . sum { |trace | trace . spans . length }
55+ end
56+
5357 context 'successful job' do
5458 subject ( :dummy_worker_success ) { worker_class . perform_async }
5559
@@ -60,19 +64,19 @@ def perform(action = :none, **_)
6064 it_behaves_like 'measured span for integration' , true do
6165 before do
6266 dummy_worker_success
63- try_wait_until { fetch_spans . length == 2 }
67+ try_wait_until { get_spans_count == 2 }
6468 end
6569 end
6670
6771 it 'generates two spans, one for pushing to enqueue and one for the job itself' do
6872 is_expected . to be true
69- try_wait_until { fetch_spans . length == 2 }
73+ try_wait_until { get_spans_count == 2 }
7074 expect ( spans . length ) . to eq ( 2 )
7175 end
7276
7377 it 'instruments successful job' do
7478 is_expected . to be true
75- try_wait_until { fetch_spans . length == 2 }
79+ try_wait_until { get_spans_count == 2 }
7680
7781 expect ( job_span . service ) . to eq ( tracer . default_service )
7882 expect ( job_span . name ) . to eq ( 'sucker_punch.perform' )
@@ -85,7 +89,7 @@ def perform(action = :none, **_)
8589
8690 it 'instruments successful enqueuing' do
8791 is_expected . to be true
88- try_wait_until { fetch_spans . length == 2 }
92+ try_wait_until { get_spans_count == 2 }
8993
9094 expect ( enqueue_span . service ) . to eq ( tracer . default_service )
9195 expect ( enqueue_span . name ) . to eq ( 'sucker_punch.perform_async' )
@@ -106,13 +110,13 @@ def perform(action = :none, **_)
106110 it_behaves_like 'measured span for integration' , true do
107111 before do
108112 dummy_worker_fail
109- try_wait_until { fetch_spans . length == 2 }
113+ try_wait_until { get_spans_count == 2 }
110114 end
111115 end
112116
113117 it 'instruments a failed job' do
114118 is_expected . to be true
115- try_wait_until { fetch_spans . length == 2 }
119+ try_wait_until { get_spans_count == 2 }
116120
117121 expect ( job_span . service ) . to eq ( tracer . default_service )
118122 expect ( job_span . name ) . to eq ( 'sucker_punch.perform' )
@@ -133,13 +137,13 @@ def perform(action = :none, **_)
133137 it_behaves_like 'measured span for integration' , true do
134138 before do
135139 dummy_worker_delay
136- try_wait_until { fetch_spans . length == 2 }
140+ try_wait_until { get_spans_count == 2 }
137141 end
138142 end
139143
140144 it 'instruments enqueuing for a delayed job' do
141145 dummy_worker_delay
142- try_wait_until { fetch_spans . length == 2 }
146+ try_wait_until { get_spans_count == 2 }
143147
144148 expect ( enqueue_span . service ) . to eq ( tracer . default_service )
145149 expect ( enqueue_span . name ) . to eq ( 'sucker_punch.perform_in' )
0 commit comments