Permalink
Browse files

Add logging for enqueued_at and perform errors

  • Loading branch information...
1 parent 1d3ba68 commit a88d9ebc0564111cd6c127a4c953ac4a607c2bf0 @mperham mperham committed May 20, 2014
@@ -32,6 +32,7 @@ def enqueue_in(interval, *args)
#
# Returns truthy if a job was scheduled.
def enqueue_at(timestamp, *args)
+ ActiveSupport::Notifications.instrument "enqueue_at.active_job", adapter: queue_adapter, timestamp: timestamp, job: self, params: args
if Time.now.to_f > timestamp
queue.adapter.queue self, *Parameters.serialize(args)
else
@@ -9,6 +9,25 @@ def enqueue(event)
info "ActiveJob enqueued to #{adapter.name.demodulize} job #{job.name}: #{params.inspect}"
end
+ def enqueue_at(event)
+ payload = event.payload
+ params = payload[:params]
+ adapter = payload[:adapter]
+ job = payload[:job]
+ time = payload[:timestamp]
+
+ info "ActiveJob enqueued at #{time} to #{adapter.name.demodulize} job #{job.name}: #{params.inspect}"
+ end
+
+ def perform_error(event)
+ payload = event.payload
+ params = payload[:params]
+ job = payload[:job]
+ error = payload[:error]
+
+ warn "ActiveJob caught error executing #{job} with #{params.inspect}: #{error.message}"
+ end
+
def logger
ActiveJob::Base.logger
end
@@ -14,7 +14,7 @@ def queue_at(job, ts, *args)
sleep(interval) if interval > 0
job.new.perform *Parameters.deserialize(args)
rescue => ex
- puts ex.message
+ ActiveSupport::Notifications.instrument "error.perform.active_job", adapter: self, job: job, params: args, error: ex
end
end
end

0 comments on commit a88d9eb

Please sign in to comment.