class HostedGraphite::Ext::Sidekiq::Metrics

Public Class Methods

new(namespace=nil) click to toggle source
# File lib/hosted_graphite/ext/sidekiq.rb, line 8
def initialize(namespace=nil)
  @client = HostedGraphite
  HostedGraphite.namespace = namespace
end

Public Instance Methods

call(worker, msg, _, &block) click to toggle source
# File lib/hosted_graphite/ext/sidekiq.rb, line 13
def call(worker, msg, _, &block)
  w = msg['wrapped'] || worker.class.to_s
  w = ['jobs', w].compact.join('.')
  begin
    @client.increment("#{w}.performed")
    @client.time("#{w}.time", &block)
    @client.increment("#{w}.succeed")
  rescue Exception
    @client.increment("#{w}.failed")
    raise
  end
end