aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/lib/active_job/exceptions.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activejob/lib/active_job/exceptions.rb')
-rw-r--r--activejob/lib/active_job/exceptions.rb32
1 files changed, 24 insertions, 8 deletions
diff --git a/activejob/lib/active_job/exceptions.rb b/activejob/lib/active_job/exceptions.rb
index 1e57dbcb1c..9a14c33d80 100644
--- a/activejob/lib/active_job/exceptions.rb
+++ b/activejob/lib/active_job/exceptions.rb
@@ -44,14 +44,24 @@ module ActiveJob
# end
def retry_on(*exceptions, wait: 3.seconds, attempts: 5, queue: nil, priority: nil)
rescue_from(*exceptions) do |error|
+ payload = {
+ job: self,
+ adapter: self.class.queue_adapter,
+ error: error,
+ wait: wait
+ }
+
if executions < attempts
- logger.error "Retrying #{self.class} in #{wait} seconds, due to a #{error.class}. The original exception was #{error.cause.inspect}."
- retry_job wait: determine_delay(wait), queue: queue, priority: priority
+ ActiveSupport::Notifications.instrument("enqueue_retry.active_job", payload) do
+ retry_job wait: determine_delay(wait), queue: queue, priority: priority
+ end
else
if block_given?
- yield self, error
+ ActiveSupport::Notifications.instrument("retry_stopped.active_job", payload) do
+ yield self, error
+ end
else
- logger.error "Stopped retrying #{self.class} due to a #{error.class}, which reoccurred on #{executions} attempts. The original exception was #{error.cause.inspect}."
+ ActiveSupport::Notifications.instrument("retry_stopped.active_job", payload)
raise error
end
end
@@ -78,10 +88,16 @@ module ActiveJob
# end
def discard_on(*exceptions)
rescue_from(*exceptions) do |error|
- if block_given?
- yield self, error
- else
- logger.error "Discarded #{self.class} due to a #{error.class}. The original exception was #{error.cause.inspect}."
+ payload = {
+ job: self,
+ adapter: self.class.queue_adapter,
+ error: error
+ }
+
+ ActiveSupport::Notifications.instrument("discard.active_job", payload) do
+ if block_given?
+ yield self, error
+ end
end
end
end