docbrown/lib/sidekiq/worker_retries_exhausted_reporter.rb
Kirk Haines ed74f2f245
Abstract DatadogStatsClient to ForemStatsClient (#12304)
* This change abstracts the DatadogStatsClient into a ForemStatsClient.
The purpose of this abstraction is to set the foundation for a subsequent PR that will allow one to use New Relic for recording Forem stats, instead of Datadog, if there is a New Relic configuration found.
This specific change creates an abstraction layer that can be built upon, without changing any actual default behavior. All specs still pass.

* Use delegate instead of explicit methods.

* Delegate instead of explicit methods.

* Fix the error.

* Refactor according to the suggestions in the comments.

* Ooops.  Stats work better when all of the code is committed.

* Removing the alias of count to increment since that was done in error.
2021-01-27 11:25:44 -05:00

19 lines
548 B
Ruby

# Any time a worker has failed and will no longer retry we want to be
# notified bc manual intervention will be needed to get the
# job to succeed.
module Sidekiq
class WorkerRetriesExhaustedReporter
def self.report_final_failure(job)
tags = [
"action:dead",
"worker_name:#{job['class']}",
"jid:#{job['jid']}",
"retry:#{job['retry']}",
"retry_count:#{job['retry_count']}",
]
ForemStatsClient.increment(
"sidekiq.worker.retries_exhausted", tags: tags
)
end
end
end