Sha256: a63b32039f664fe6028277dfcb541781c95571672fbbddb5c2b861c133402ba8
Contents?: true
Size: 1.18 KB
Versions: 14
Compression:
Stored size: 1.18 KB
Contents
require 'delayed_job' require 'rollbar/plugins/delayed_job/job_data' module Rollbar module Delayed class << self attr_accessor :wrapped end class RollbarPlugin < ::Delayed::Plugin callbacks do |lifecycle| lifecycle.around(:invoke_job, &Delayed::invoke_job_callback) end end self.wrapped = false def self.wrap_worker return if wrapped ::Delayed::Worker.plugins << RollbarPlugin self.wrapped = true end def self.wrap_worker! self.wrapped = false wrap_worker end def self.invoke_job_callback proc do |job, *args, &block| begin block.call(job, *args) rescue => e report(e, job) raise e end end end def self.report(e, job) return if skip_report?(job) data = build_job_data(job) ::Rollbar.scope(:request => data).error(e, :use_exception_level_filters => true) end def self.skip_report?(job) job.attempts < ::Rollbar.configuration.dj_threshold end def self.build_job_data(job) return nil unless ::Rollbar.configuration.report_dj_data JobData.new(job).to_hash end end end
Version data entries
14 entries across 14 versions & 1 rubygems