Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add queue latency for Sidekiq jobs in NR
- Loading branch information
1 parent
e03db66
commit c32a2eb
Showing
1 changed file
with
13 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class NewRelicQueueLatencyLogger | ||
def call(worker, job, queue) | ||
queue_latency = Time.now.utc - Time.at(job["enqueued_at"], in: "+00:00") | ||
::NewRelic::Agent.add_custom_attributes({ queue_latency: queue_latency, queue: queue }) | ||
yield | ||
end | ||
end | ||
|
||
Sidekiq.configure_server do |config| | ||
config.server_middleware do |chain| | ||
chain.add NewRelicQueueLatencyLogger | ||
end | ||
end |