Sha256: 5e3b29c9372b2decf2348bef2b45490ef4f5a4836db7340ecda9f55bda058fc5

Contents?: true

Size: 854 Bytes

Versions: 6

Compression:

Stored size: 854 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
      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

6 entries across 6 versions & 2 rubygems

Version Path
newrelic_rpm-2.9.9 lib/new_relic/agent/samplers/mongrel_sampler.rb
newrelic_rpm-2.9.8 lib/new_relic/agent/samplers/mongrel_sampler.rb
newrelic_rpm-2.9.6 lib/new_relic/agent/samplers/mongrel_sampler.rb
genki-newrelic_rpm-2.10.1 lib/new_relic/agent/samplers/mongrel_sampler.rb
newrelic_rpm-2.9.5 lib/new_relic/agent/samplers/mongrel_sampler.rb
newrelic_rpm-2.9.4 lib/new_relic/agent/samplers/mongrel_sampler.rb