【发布时间】:2016-02-18 01:50:59
【问题描述】:
我正在使用 sidekiq 每小时处理数千个作业 - 所有这些作业都 ping 外部 API (Google)。 X 千个请求中的一个将返回意外(或空)的结果。据我所知,这在处理外部 API 时是不可避免的。
目前,当我遇到这样的响应时,我会引发一个异常,以便重试逻辑在下一次尝试时自动处理它。只有同一个工作多次失败才是真正的错误。异常由 Airbrake 处理。
但是,我的空气制动器被这些并非真正“问题”的小型停机堵塞了。 我希望 Airbrake 仅在同一个作业已经失败 X 次时才收到这些问题的通知。
有没有可能
- 禁用自动 airbrake 集成,以便我可以使用 sidekiq_retries_exhausted 通过 Airbrake.notify 手动报告错误
- 以某种方式挽救错误,使其不通知 Airbrake 而是继续重试?
- 以我没有想到的不同方式执行此操作?
这是我的代码大纲
class GoogleApiWorker
include Sidekiq::Worker
sidekiq_options queue: :critical, backtrace: 5
def perform
# Do stuff interacting with the google API
rescue Exception => e
if is_a_mini_google_outage? e
# How do i make it so this harmless error DOES NOT get reported to Airbrake but still gets retried?
raise e
end
end
def is_a_mini_google_outage? e
# check to see if this is a harmless outage
end
end
【问题讨论】:
标签: ruby-on-rails sidekiq airbrake