@@ -81,8 +81,9 @@ class InstrumentationTest < ActiveSupport::TestCase
81
81
end
82
82
83
83
test "errors when deregistering processes are included in deregister_process events" do
84
- SolidQueue ::Process . any_instance . expects ( :destroy! ) . raises ( RuntimeError . new ( "everything is broken" ) ) . at_least_once
85
- Thread . report_on_exception = false
84
+ previous_thread_report_on_exception , Thread . report_on_exception = Thread . report_on_exception , false
85
+ error = RuntimeError . new ( "everything is broken" )
86
+ SolidQueue ::Process . any_instance . expects ( :destroy! ) . raises ( error ) . at_least_once
86
87
87
88
events = subscribed ( "deregister_process.solid_queue" ) do
88
89
assert_raises RuntimeError do
@@ -95,9 +96,9 @@ class InstrumentationTest < ActiveSupport::TestCase
95
96
end
96
97
97
98
assert_equal 1 , events . size
98
- assert events . first . last [ : error] . is_a? ( RuntimeError )
99
+ assert_event events . first , "deregister_process" , error : error
99
100
ensure
100
- Thread . report_on_exception = true
101
+ Thread . report_on_exception = previous_thread_report_on_exception
101
102
end
102
103
103
104
test "retrying failed job emits retry event" do
@@ -260,6 +261,27 @@ class InstrumentationTest < ActiveSupport::TestCase
260
261
end
261
262
end
262
263
264
+ test "thread errors emit thread_error events" do
265
+ previous_thread_report_on_exception , Thread . report_on_exception = Thread . report_on_exception , false
266
+
267
+ error = RuntimeError . new ( "everything is broken" )
268
+ SolidQueue ::ClaimedExecution ::Result . expects ( :new ) . raises ( error ) . at_least_once
269
+
270
+ AddToBufferJob . perform_later "hey!"
271
+
272
+ events = subscribed ( "thread_error.solid_queue" ) do
273
+ SolidQueue ::Worker . new . tap do |worker |
274
+ worker . mode = :inline
275
+ worker . start
276
+ end
277
+ end
278
+
279
+ assert_equal 1 , events . count
280
+ assert_event events . first , "thread_error" , error : error
281
+ ensure
282
+ Thread . report_on_exception = previous_thread_report_on_exception
283
+ end
284
+
263
285
private
264
286
def subscribed ( name , &block )
265
287
[ ] . tap do |events |
0 commit comments