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
Class Method Summary
collapse
Instance Method Summary
collapse
inherited, sampler_classes
Constructor Details
Returns a new instance of DelayedJobSampler.
Class Method Details
48
49
50
|
# File 'lib/new_relic/agent/samplers/delayed_job_sampler.rb', line 48
def self.supported_on_this_platform?
defined?(Delayed::Job)
end
|
Instance Method Details
#failed_jobs ⇒ Object
41
42
43
|
# File 'lib/new_relic/agent/samplers/delayed_job_sampler.rb', line 41
def failed_jobs
Delayed::Job.count(:conditions => 'failed_at is not NULL')
end
|
#local_env ⇒ Object
33
34
35
|
# File 'lib/new_relic/agent/samplers/delayed_job_sampler.rb', line 33
def local_env
NewRelic::Control.instance.local_env
end
|
#locked_jobs ⇒ Object
44
45
46
|
# File 'lib/new_relic/agent/samplers/delayed_job_sampler.rb', line 44
def locked_jobs
Delayed::Job.count(:conditions => 'locked_by is not NULL')
end
|
#poll ⇒ Object
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/new_relic/agent/samplers/delayed_job_sampler.rb', line 52
def poll
record_failed_jobs(failed_jobs)
record_locked_jobs(locked_jobs)
if @queue
record_queue_length_across_dimension('queue')
else
record_queue_length_across_dimension('priority')
end
end
|
#record_failed_jobs(value) ⇒ Object
25
26
27
|
# File 'lib/new_relic/agent/samplers/delayed_job_sampler.rb', line 25
def record_failed_jobs(value)
NewRelic::Agent.record_metric("Workers/DelayedJob/failed_jobs", value)
end
|
#record_locked_jobs(value) ⇒ Object
29
30
31
|
# File 'lib/new_relic/agent/samplers/delayed_job_sampler.rb', line 29
def record_locked_jobs(value)
NewRelic::Agent.record_metric("Workers/DelayedJob/locked_jobs", value)
end
|
#worker_name ⇒ Object
37
38
39
|
# File 'lib/new_relic/agent/samplers/delayed_job_sampler.rb', line 37
def worker_name
local_env.dispatcher_instance_id
end
|