Skip to content

Commit

Permalink
Add queue latency for Sidekiq jobs in NR
Browse files Browse the repository at this point in the history
  • Loading branch information
nateberkopec committed Mar 12, 2021
1 parent e03db66 commit c32a2eb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions config/initializers/nr_sidekiq_queue_latency.rb
@@ -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

0 comments on commit c32a2eb

Please sign in to comment.