Sha256: 767d0c65f6e3c0c83de9e8efc9239bb9ecd65a5fd556250db5ef55cd57885fa9
Contents?: true
Size: 1.48 KB
Versions: 8
Compression:
Stored size: 1.48 KB
Contents
require 'honeybadger/plugin' require 'honeybadger/ruby' module Honeybadger module Plugins module Faktory class Middleware def call(worker, job) Honeybadger.clear! yield end end Plugin.register do requirement { defined?(::Faktory) } execution do return unless Honeybadger.config[:'exceptions.enabled'] ::Faktory.configure_worker do |faktory| faktory.worker_middleware do |chain| chain.prepend Middleware end end ::Faktory.configure_worker do |faktory| faktory.error_handlers << lambda do |ex, params| opts = {parameters: params} if job = params[:job] if (threshold = config[:'faktory.attempt_threshold'].to_i) > 0 # If job.failure is nil, it is the first attempt. The first # retry has a job.failure.retry_count of 0, which would be # the second attempt in our case. retry_count = job.dig('failure', 'retry_count') attempt = retry_count ? retry_count + 1 : 0 limit = [job['retry'].to_i, threshold].min return if attempt < limit end opts[:component] = job['jobtype'] opts[:action] = 'perform' end Honeybadger.notify(ex, opts) end end end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems