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
|