Class: Nightwing::Sidekiq::Stats

Inherits:
Base
  • Object
show all
Defined in:
lib/nightwing/sidekiq/stats.rb

Overview

Sidekiq server middleware for measuring Sidekiq stats

Instance Attribute Summary

Attributes inherited from Base

#logger, #namespace

Instance Method Summary collapse

Methods inherited from Base

#client, #initialize

Constructor Details

This class inherits a constructor from Nightwing::Sidekiq::Base

Instance Method Details

#call(_worker, _msg, _queue) ⇒ Object

Sends Sidekiq metrics to statsd client then yields

Parameters:

  • _worker (Sidekiq::Worker)

    The worker the job belongs to.

  • _msg (Hash)

    The job message.

  • _queue (String)

    The current queue.



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/nightwing/sidekiq/stats.rb', line 19

def call(_worker, _msg, _queue)
  client.measure "#{namespace}.retries", retries.size
  client.measure "#{namespace}.scheduled", scheduled.size
  client.increment "#{namespace}.processed"

  begin
    yield
  rescue
    client.increment "#{namespace}.failed"
    raise
  end
end