Last Updated: February 25, 2016
·
1.026K
· seyhunak

Sidekiq + Newrelic Exception Notifier

require 'sidekiq'

module NewRelic
  class SidekiqException
    def call(worker, msg, queue)
      begin
        yield
      rescue => exception
        NewRelic::Agent.notice_error(exception, :custom_params => msg)
        raise exception
      end
    end
  end
end

::Sidekiq.configure_server do |config|
  config.server_middleware do |chain|
    chain.add ::NewRelic::SidekiqException
  end
end