Class: NewRelic::Agent::Samplers::MongrelSampler
- Inherits:
-
NewRelic::Agent::Sampler
- Object
- NewRelic::Agent::Sampler
- NewRelic::Agent::Samplers::MongrelSampler
- Defined in:
- lib/new_relic/agent/samplers/mongrel_sampler.rb
Overview
NewRelic Instrumentation for Mongrel - tracks the queue length of the mongrel server.
Instance Attribute Summary
Attributes inherited from NewRelic::Agent::Sampler
Instance Method Summary collapse
-
#initialize ⇒ MongrelSampler
constructor
A new instance of MongrelSampler.
- #poll ⇒ Object
- #queue_stats ⇒ Object
Methods inherited from NewRelic::Agent::Sampler
inherited, sampler_classes, supported_on_this_platform?, use_harvest_sampler?
Constructor Details
#initialize ⇒ MongrelSampler
Returns a new instance of MongrelSampler.
4 5 6 7 |
# File 'lib/new_relic/agent/samplers/mongrel_sampler.rb', line 4 def initialize super :mongrel raise Unsupported, "Mongrel not running" unless NewRelic::Control.instance.local_env.mongrel end |
Instance Method Details
#poll ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/new_relic/agent/samplers/mongrel_sampler.rb', line 11 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 |
#queue_stats ⇒ Object
8 9 10 |
# File 'lib/new_relic/agent/samplers/mongrel_sampler.rb', line 8 def queue_stats stats_engine.get_stats("Mongrel/Queue Length", false) end |