39
39
end
40
40
41
41
let ( :expect_thread? ) { true }
42
- let ( :mutex ) { Mutex . new }
43
42
44
43
let ( :worker_class ) do
45
44
Class . new do
@@ -51,12 +50,6 @@ def perform(action = :none, **_)
51
50
end
52
51
end
53
52
54
- def check_spans_count_eq ( count )
55
- mutex . synchronize do
56
- try_wait_until { get_spans_count == count }
57
- end
58
- end
59
-
60
53
context 'successful job' do
61
54
subject ( :dummy_worker_success ) { worker_class . perform_async }
62
55
@@ -67,19 +60,19 @@ def check_spans_count_eq(count)
67
60
it_behaves_like 'measured span for integration' , true do
68
61
before do
69
62
dummy_worker_success
70
- check_spans_count_eq ( 2 )
63
+ try_wait_until { get_spans_count == 2 }
71
64
end
72
65
end
73
66
74
67
it 'generates two spans, one for pushing to enqueue and one for the job itself' do
75
68
is_expected . to be true
76
- check_spans_count_eq ( 2 )
69
+ try_wait_until { get_spans_count == 2 }
77
70
expect ( spans . length ) . to eq ( 2 )
78
71
end
79
72
80
73
it 'instruments successful job' do
81
74
is_expected . to be true
82
- check_spans_count_eq ( 2 )
75
+ try_wait_until { get_spans_count == 2 }
83
76
84
77
expect ( job_span . service ) . to eq ( tracer . default_service )
85
78
expect ( job_span . name ) . to eq ( 'sucker_punch.perform' )
@@ -92,7 +85,7 @@ def check_spans_count_eq(count)
92
85
93
86
it 'instruments successful enqueuing' do
94
87
is_expected . to be true
95
- check_spans_count_eq ( 2 )
88
+ try_wait_until { get_spans_count == 2 }
96
89
97
90
expect ( enqueue_span . service ) . to eq ( tracer . default_service )
98
91
expect ( enqueue_span . name ) . to eq ( 'sucker_punch.perform_async' )
@@ -113,13 +106,13 @@ def check_spans_count_eq(count)
113
106
it_behaves_like 'measured span for integration' , true do
114
107
before do
115
108
dummy_worker_fail
116
- check_spans_count_eq ( 2 )
109
+ try_wait_until { get_spans_count == 2 }
117
110
end
118
111
end
119
112
120
113
it 'instruments a failed job' do
121
114
is_expected . to be true
122
- check_spans_count_eq ( 2 )
115
+ try_wait_until { get_spans_count == 2 }
123
116
124
117
expect ( job_span . service ) . to eq ( tracer . default_service )
125
118
expect ( job_span . name ) . to eq ( 'sucker_punch.perform' )
@@ -140,13 +133,13 @@ def check_spans_count_eq(count)
140
133
it_behaves_like 'measured span for integration' , true do
141
134
before do
142
135
dummy_worker_delay
143
- check_spans_count_eq ( 2 )
136
+ try_wait_until { get_spans_count == 2 }
144
137
end
145
138
end
146
139
147
140
it 'instruments enqueuing for a delayed job' do
148
141
dummy_worker_delay
149
- check_spans_count_eq ( 2 )
142
+ try_wait_until { get_spans_count == 2 }
150
143
151
144
expect ( enqueue_span . service ) . to eq ( tracer . default_service )
152
145
expect ( enqueue_span . name ) . to eq ( 'sucker_punch.perform_in' )
0 commit comments