Sha256: 05a7b0e5f289256b0d51b37d4157be14fc1d774e5225162f471314a8b79f0d9f

Contents?: true

Size: 978 Bytes

Versions: 12

Compression:

Stored size: 978 Bytes

Contents

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

12 entries across 12 versions & 2 rubygems

Version Path
newrelic_rpm-2.13.4.rum6 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
newrelic_rpm-2.13.4.rum5 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
newrelic_rpm-2.13.4.rum4 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
newrelic_rpm-2.13.4.eum3 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
newrelic_rpm-2.13.4.eum2 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
newrelic_rpm-2.13.4.eum1 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
newrelic_rpm-2.13.4 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
newrelic_rpm-2.13.3 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
newrelic_rpm-2.13.3.beta lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
newrelic_rpm-2.13.2 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
honkster-newrelic_rpm-2.13.1 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb
newrelic_rpm-2.13.1 lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb