tombwg
Last Updated: February 25, 2016
·
855
· 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