Sha256: c8cfd0b3ff0a6efda2c36acac6809e3c5f84b0cab7b53700282ca63963890a9b

Contents?: true

Size: 871 Bytes

Versions: 2

Compression:

Stored size: 871 Bytes

Contents

module NewRelic::Agent::Samplers
  # NewRelic Instrumentation for Mongrel - tracks the queue length of the mongrel server.
  class MongrelSampler < NewRelic::Agent::Sampler
    def initialize
      super :mongrel
    end
    def queue_stats
      @queue_stats ||= stats_engine.get_stats("Mongrel/Queue Length", false)
    end
    def poll
      mongrel = NewRelic::Control.instance.local_env.mongrel
      if mongrel
        # The mongrel workers list includes workers actively processing requests
        # so you need to subtract what appears to be the active workers from the total
        # number of workers to get the queue size.
        qsize = mongrel.workers.list.length - NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.busy_count
        qsize = 0 if qsize < 0
        queue_stats.record_data_point qsize
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
newrelic_rpm-2.9.2 lib/new_relic/agent/samplers/mongrel_sampler.rb
newrelic_rpm-2.9.3 lib/new_relic/agent/samplers/mongrel_sampler.rb