Skip to content

Commit 50f2341

Browse files
committed
Make job.instrument public with nodoc
1 parent c7c72ee commit 50f2341

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

activejob/lib/active_job/continuation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def instrument_job(event)
315315
end
316316

317317
def instrument(event, payload = {})
318-
job.send(:instrument, event, **payload)
318+
job.instrument event, **payload
319319
end
320320
end
321321
end

activejob/lib/active_job/instrumentation.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,24 @@ def perform_now
2626
instrument(:perform) { super }
2727
end
2828

29+
def instrument(operation, payload = {}, &block) # :nodoc:
30+
payload[:job] = self
31+
payload[:adapter] = queue_adapter
32+
33+
ActiveSupport::Notifications.instrument("#{operation}.active_job", payload) do
34+
value = block.call if block
35+
payload[:aborted] = @_halted_callback_hook_called if defined?(@_halted_callback_hook_called)
36+
@_halted_callback_hook_called = nil
37+
value
38+
end
39+
end
40+
2941
private
3042
def _perform_job
3143
instrument(:perform_start)
3244
super
3345
end
3446

35-
def instrument(operation, payload = {}, &block)
36-
payload[:job] = self
37-
payload[:adapter] = queue_adapter
38-
39-
ActiveSupport::Notifications.instrument("#{operation}.active_job", payload) do
40-
value = block.call if block
41-
payload[:aborted] = @_halted_callback_hook_called if defined?(@_halted_callback_hook_called)
42-
@_halted_callback_hook_called = nil
43-
value
44-
end
45-
end
46-
4747
def halted_callback_hook(*)
4848
super
4949
@_halted_callback_hook_called = true

activerecord/lib/active_record/railties/job_runtime.rb

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@
55
module ActiveRecord
66
module Railties # :nodoc:
77
module JobRuntime # :nodoc:
8-
private
9-
def instrument(operation, payload = {}, &block)
10-
if operation == :perform && block
11-
super(operation, payload) do
12-
db_runtime_before_perform = ActiveRecord::RuntimeRegistry.sql_runtime
13-
result = block.call
14-
payload[:db_runtime] = ActiveRecord::RuntimeRegistry.sql_runtime - db_runtime_before_perform
15-
result
16-
end
17-
else
18-
super
8+
def instrument(operation, payload = {}, &block) # :nodoc:
9+
if operation == :perform && block
10+
super(operation, payload) do
11+
db_runtime_before_perform = ActiveRecord::RuntimeRegistry.sql_runtime
12+
result = block.call
13+
payload[:db_runtime] = ActiveRecord::RuntimeRegistry.sql_runtime - db_runtime_before_perform
14+
result
1915
end
16+
else
17+
super
2018
end
19+
end
2120
end
2221
end
2322
end

0 commit comments

Comments
 (0)