Class: Nightwing::Sidekiq::WorkerStats

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

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



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/nightwing/sidekiq/worker_stats.rb', line 6

def call(worker, msg, queue)
  worker_namespace = metrics.for(queue: queue, worker: worker.class)

  client.increment "#{worker_namespace}.processed"

  if msg["retry"]
    if msg["retry_count"].to_i > 0
      client.increment "#{worker_namespace}.retried"
    end
  end

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

  client.increment "#{worker_namespace}.finished"
end