aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/active_job/enqueuing.rb12
-rw-r--r--lib/active_job/performing.rb7
2 files changed, 14 insertions, 5 deletions
diff --git a/lib/active_job/enqueuing.rb b/lib/active_job/enqueuing.rb
index 652de5521b..e8f3272782 100644
--- a/lib/active_job/enqueuing.rb
+++ b/lib/active_job/enqueuing.rb
@@ -11,7 +11,7 @@ module ActiveJob
# ActiveJob release.
def enqueue(*args)
serialized_args = Parameters.serialize(args)
- ActiveSupport::Notifications.instrument "enqueue.active_job", adapter: queue_adapter, job: self, args: serialized_args
+ instrument_enqueuing :enqueue, args: serialized_args
queue_adapter.enqueue self, *serialized_args
end
@@ -30,10 +30,14 @@ module ActiveJob
#
# Returns truthy if a job was scheduled.
def enqueue_at(timestamp, *args)
- timestamp = timestamp.to_f
serialized_args = Parameters.serialize(args)
- ActiveSupport::Notifications.instrument "enqueue_at.active_job", adapter: queue_adapter, job: self, args: serialized_args, timestamp: timestamp
- queue_adapter.enqueue_at self, timestamp, *serialized_args
+ instrument_enqueuing :enqueue_at, args: serialized_args, timestamp: timestamp
+ queue_adapter.enqueue_at self, timestamp.to_f, *serialized_args
end
+
+ private
+ def instrument_enqueuing(method_name, options = {})
+ ActiveSupport::Notifications.instrument "#{method_name}.active_job", options.merge(adapter: queue_adapter, job: self)
+ end
end
end
diff --git a/lib/active_job/performing.rb b/lib/active_job/performing.rb
index 6c304a4bed..eca311578d 100644
--- a/lib/active_job/performing.rb
+++ b/lib/active_job/performing.rb
@@ -3,12 +3,17 @@ require 'active_job/parameters'
module ActiveJob
module Performing
def perform_with_deserialization(*serialized_args)
- ActiveSupport::Notifications.instrument "perform.active_job", adapter: self.class.queue_adapter, job: self.class, args: serialized_args
+ instrument_performing serialized_args
perform *Parameters.deserialize(serialized_args)
end
def perform(*)
raise NotImplementedError
end
+
+ private
+ def instrument_performing(args)
+ ActiveSupport::Notifications.instrument "perform.active_job", adapter: self.class.queue_adapter, job: self.class, args: args
+ end
end
end