Skip to content

Commit b0671d3

Browse files
authored
test(vernier): Cleanup stop_profile properly (#3163)
1 parent fbf949b commit b0671d3

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎sentry-ruby/spec/sentry/vernier/profiler_spec.rb‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
end
1717
end
1818

19+
after do
20+
Vernier.stop_profile if Vernier.instance_variable_get(:@collector)
21+
end
22+
1923
let(:profiles_sample_rate) { 1.0 }
2024
let(:traces_sample_rate) { 1.0 }
2125

@@ -147,7 +151,7 @@
147151
it 'stops Vernier if sampled and started' do
148152
profiler.set_initial_sample_decision(true)
149153
profiler.start
150-
expect(Vernier).to receive(:stop_profile)
154+
expect(Vernier).to receive(:stop_profile).and_call_original
151155
profiler.stop
152156
end
153157

@@ -161,7 +165,10 @@
161165
it 'does not crash when stopping Vernier crashed' do
162166
profiler.set_initial_sample_decision(true)
163167
profiler.start
164-
expect(Vernier).to receive(:stop_profile).and_raise(RuntimeError.new("Profile not started"))
168+
expect(Vernier).to receive(:stop_profile).and_wrap_original do |stop_profile|
169+
stop_profile.call
170+
raise RuntimeError.new("Profile not started")
171+
end
165172
profiler.stop
166173
end
167174
end

0 commit comments

Comments
 (0)