Sha256: 8ce33125ee3008666d1c3af84d8cd3329ec0f4cf013f6b50219a54cf569f48df

Contents?: true

Size: 909 Bytes

Versions: 1

Compression:

Stored size: 909 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
      raise Unsupported, "Mongrel not running" unless NewRelic::Control.instance.local_env.mongrel
    end
    def 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::BusyCalculator.busy_count
        qsize = 0 if qsize < 0
        queue_stats.record_data_point qsize
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
factorylabs-newrelic_rpm-2.10.2.2 lib/new_relic/agent/samplers/mongrel_sampler.rb