Sha256: f622da0fca8e66c510719f98bc8a412ae5611f28aeb331d309cc1f9157039fcd

Contents?: true

Size: 1.03 KB

Versions: 57

Compression:

Stored size: 1.03 KB

Contents

require 'new_relic/agent/sampler'
require 'new_relic/delayed_job_injection'

module NewRelic
  module Agent
    module Samplers
      class DelayedJobLockSampler < NewRelic::Agent::Sampler
        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

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

        def local_env
          NewRelic::Control.instance.local_env
        end

        def worker_name
          local_env.dispatcher_instance_id
        end

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

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

        def poll
          stats.record_data_point locked_jobs
        end
      end
    end
  end
end

Version data entries

57 entries across 57 versions & 4 rubygems

Version Path
dolores_rpm-3.3.4.8 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
dolores_rpm-3.3.4.7 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
dolores_rpm-3.3.4.6 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
dolores_rpm-3.3.4.5 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
dolores_rpm-3.3.4.4 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
dolores_rpm-3.3.4.3 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
dolores_rpm-3.3.4.1.fork2 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
dolores_rpm-3.3.4.1.fork lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
dolores_rpm-3.2.0.6 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
wd_newrelic_rpm-3.3.4.1 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
dolores_rpm-3.2.0.5 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
dolores_rpm-3.2.0.4 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
dolores_rpm-3.2.0.3 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
dolores_rpm-3.2.0.2 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
dolores_rpm-3.3.4.fork lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
newrelic_rpm-3.3.4.1 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
newrelic_rpm-3.3.4 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
newrelic_rpm-3.3.4.beta1 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
newrelic_rpm-3.3.3 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
newrelic_rpm-3.3.3.beta2 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb