Module: IuguLogger::JobLogger::ActiveJob

Defined in:
lib/iugu_logger/job_logger.rb

Overview

ActiveJob mixin. ‘include` in ApplicationJob to capture all jobs. ActiveJob >= 5 has #executions; we fall back to 1 on Rails 4.2 (platform).

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



158
159
160
161
162
163
164
165
166
167
168
# File 'lib/iugu_logger/job_logger.rb', line 158

def self.included(base)
  base.around_perform do |job, block|
    Adapter.new(
      job_class: job.class.name,
      job_id:    job.job_id,
      queue:     job.queue_name,
      source:    SOURCE_ACTIVEJOB,
      attempt:   job.respond_to?(:executions) ? job.executions : 1
    ).call { block.call }
  end
end