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
41
42
43
|
# File 'lib/new_relic/agent/samplers/delayed_job_sampler.rb', line 41
def self.supported_on_this_platform?
defined?(Delayed::Job)
end
|
Instance Method Details
#failed_jobs ⇒ Object
33
34
35
|
# File 'lib/new_relic/agent/samplers/delayed_job_sampler.rb', line 33
def failed_jobs
Delayed::Job.count(:conditions => 'failed_at is not NULL')
end
|
#locked_jobs ⇒ Object
37
38
39
|
# File 'lib/new_relic/agent/samplers/delayed_job_sampler.rb', line 37
def locked_jobs
Delayed::Job.count(:conditions => 'locked_by is not NULL')
end
|
#poll ⇒ Object
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/new_relic/agent/samplers/delayed_job_sampler.rb', line 45
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
|