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:



8
9
10
11
12
# File 'lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb', line 8

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)


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

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

Instance Method Details

#local_envObject



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

def local_env
  NewRelic::Control.instance.local_env
end

#locked_jobsObject



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

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

#pollObject



34
35
36
# File 'lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb', line 34

def poll
  stats.record_data_point locked_jobs
end

#statsObject



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

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

#worker_nameObject



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

def worker_name
  local_env.dispatcher_instance_id
end