Class: NewRelic::Agent::Samplers::DelayedJobSampler
Overview
This sampler records the status of your delayed job table once a minute. It assumes jobs are cleared after being run, and failed jobs are not (otherwise the failed job metric is useless).
In earlier versions it will break out the queue length by priority. In later versions of DJ where distinct queues are supported, it breaks it out by queue name.
Instance Attribute Summary
#id, #stats_engine
Class Method Summary
collapse
Instance Method Summary
collapse
inherited, sampler_classes, use_harvest_sampler?
Constructor Details
Returns a new instance of DelayedJobSampler.
Class Method Details
43
44
45
|
# File 'lib/new_relic/agent/samplers/delayed_job_sampler.rb', line 43
def self.supported_on_this_platform?
defined?(Delayed::Job)
end
|
Instance Method Details
#error_stats ⇒ Object
21
22
23
|
# File 'lib/new_relic/agent/samplers/delayed_job_sampler.rb', line 21
def error_stats
stats_engine.get_stats("Workers/DelayedJob/failed_jobs", false)
end
|
#failed_jobs ⇒ Object
36
37
38
|
# File 'lib/new_relic/agent/samplers/delayed_job_sampler.rb', line 36
def failed_jobs
Delayed::Job.count(:conditions => 'failed_at is not NULL')
end
|
#local_env ⇒ Object
28
29
30
|
# File 'lib/new_relic/agent/samplers/delayed_job_sampler.rb', line 28
def local_env
NewRelic::Control.instance.local_env
end
|
#locked_job_stats ⇒ Object
24
25
26
|
# File 'lib/new_relic/agent/samplers/delayed_job_sampler.rb', line 24
def locked_job_stats
stats_engine.get_stats("Workers/DelayedJob/locked_jobs", false)
end
|
#locked_jobs ⇒ Object
39
40
41
|
# File 'lib/new_relic/agent/samplers/delayed_job_sampler.rb', line 39
def locked_jobs
Delayed::Job.count(:conditions => 'locked_by is not NULL')
end
|
#poll ⇒ Object
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/new_relic/agent/samplers/delayed_job_sampler.rb', line 47
def poll
record error_stats, failed_jobs
record locked_job_stats, locked_jobs
if @queue
record_queue_length_across_dimension('queue')
else
record_queue_length_across_dimension('priority')
end
end
|
#worker_name ⇒ Object
32
33
34
|
# File 'lib/new_relic/agent/samplers/delayed_job_sampler.rb', line 32
def worker_name
local_env.dispatcher_instance_id
end
|