How do i integrate Hoptoad with DelayedJob and DaemonSpawn?

后端 未结 4 1801
渐次进展
渐次进展 2021-02-06 13:13

I have been happily using the DelayedJob idiom:

foo.send_later(:bar)

This calls the method bar on the object foo in the DelayedJob process.

4条回答
  •  臣服心动
    2021-02-06 13:30

    Check out the source for Delayed::Job... there's a snippet like:

    # This is a good hook if you need to report job processing errors in additional or different ways
    def log_exception(error)
      logger.error "* [JOB] #{name} failed with #{error.class.name}: #{error.message} - #{attempts} failed attempts"
      logger.error(error)
    end
    

    I haven't tried it, but I think you could do something like:

    class Delayed::Job
      def log_exception_with_hoptoad(error)
        log_exception_without_hoptoad(error)
        HoptoadNotifier.notify(error)
      end
    
      alias_method_chain :log_exception, :hoptoad
    end
    

提交回复
热议问题