diff options
Diffstat (limited to 'lib/active_job')
-rw-r--r-- | lib/active_job/enqueuing.rb | 1 | ||||
-rw-r--r-- | lib/active_job/log_subscriber.rb | 19 | ||||
-rw-r--r-- | lib/active_job/queue_adapters/inline_adapter.rb | 2 |
3 files changed, 21 insertions, 1 deletions
diff --git a/lib/active_job/enqueuing.rb b/lib/active_job/enqueuing.rb index 1e0dd58b59..bb681d1e32 100644 --- a/lib/active_job/enqueuing.rb +++ b/lib/active_job/enqueuing.rb @@ -32,6 +32,7 @@ module ActiveJob # # 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 diff --git a/lib/active_job/log_subscriber.rb b/lib/active_job/log_subscriber.rb index 31c61a6068..2c389ed431 100644 --- a/lib/active_job/log_subscriber.rb +++ b/lib/active_job/log_subscriber.rb @@ -9,6 +9,25 @@ module ActiveJob 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 diff --git a/lib/active_job/queue_adapters/inline_adapter.rb b/lib/active_job/queue_adapters/inline_adapter.rb index dd4b3f4fc0..cad600a765 100644 --- a/lib/active_job/queue_adapters/inline_adapter.rb +++ b/lib/active_job/queue_adapters/inline_adapter.rb @@ -14,7 +14,7 @@ module ActiveJob 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 |