Class: NewRelicResqueAgent::Agent

Inherits:
NewRelic::Plugin::Agent::Base
  • Object
show all
Defined in:
lib/newrelic_resque_agent.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#identObject (readonly)

Returns the value of attribute ident.



21
22
23
# File 'lib/newrelic_resque_agent.rb', line 21

def ident
  @ident
end

Instance Method Details

#poll_cycleObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/newrelic_resque_agent.rb', line 28

def poll_cycle
  if redis.nil?
    raise "Redis connection URL "
  end

  begin
    Resque.redis = redis
    Resque.redis.namespace = namespace unless namespace.nil?
    info = Resque.info
    
    report_metric "Workers/Working", "Workers",           info[:working]
    report_metric "Workers/Total", "Workers",             info[:workers]
    report_metric "Jobs/Pending", "Jobs",                 info[:pending]
    report_metric "Jobs/Rate/Processed", "Jobs/Second",        @processed.process(info[:processed])
    report_metric "Jobs/Rate/Failed", "Jobs/Second",           @total_failed.process(info[:failed])
    report_metric "Queues", "Queues",                     info[:queues]
    report_metric "Jobs/Failed", "Jobs",                  info[:failed] || 0
    
    

  rescue Redis::TimeoutError
    raise 'Redis server timeout'
  rescue  Redis::CannotConnectError, Redis::ConnectionError
    raise 'Could not connect to redis'
  rescue Errno::ECONNRESET
    raise 'Connection was reset by peer'
  end
end

#setup_metricsObject



23
24
25
26
# File 'lib/newrelic_resque_agent.rb', line 23

def setup_metrics
  @total_failed = NewRelic::Processor::EpochCounter.new
  @processed    = NewRelic::Processor::EpochCounter.new
end