Class: NewRelic::Agent::Samplers::DelayedJobLockSampler

Inherits:
NewRelic::Agent::Sampler show all
Defined in:
lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb

Instance Attribute Summary

Attributes inherited from NewRelic::Agent::Sampler

#id, #stats_engine

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from NewRelic::Agent::Sampler

inherited, sampler_classes, use_harvest_sampler?

Constructor Details

#initializeDelayedJobLockSampler

Returns a new instance of DelayedJobLockSampler.

Raises:



5
6
7
8
9
# File 'lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb', line 5

def initialize
  super :delayed_job_lock
  raise Unsupported, "DJ instrumentation disabled" if NewRelic::Control.instance['disable_dj'] 
  raise Unsupported, "No DJ worker present" unless NewRelic::DelayedJobInjection.worker_name
end

Class Method Details

.supported_on_this_platform?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb', line 27

def self.supported_on_this_platform?
  defined?(Delayed::Job)
end

Instance Method Details

#local_envObject



15
16
17
# File 'lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb', line 15

def local_env
  NewRelic::Control.instance.local_env
end

#locked_jobsObject



23
24
25
# File 'lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb', line 23

def locked_jobs
  Delayed::Job.count(:conditions => {:locked_by => NewRelic::DelayedJobInjection.worker_name})
end

#pollObject



31
32
33
# File 'lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb', line 31

def poll
  stats.record_data_point locked_jobs
end

#statsObject



11
12
13
# File 'lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb', line 11

def stats
  stats_engine.get_stats("Custom/DJ Locked Jobs", false)
end

#worker_nameObject



19
20
21
# File 'lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb', line 19

def worker_name
  local_env.dispatcher_instance_id
end