class AppDynamics::BackgroundMetrics::Threads

Public Instance Methods

instrument!(state, counters, gauges) click to toggle source
# File lib/app_dynamics/background_metrics.rb, line 105
def instrument!(state, counters, gauges)
  alive = 0
  running = 0
  sleeping = 0

  Thread.list.each do |t|
    if t.alive?
      alive += 1
      if t.stop?
        sleeping += 1
      else
        running += 1
      end
    end
  end

  gauges[:'Threads.alive'] = alive
  gauges[:'Threads.running'] = running
  gauges[:'Threads.sleeping'] = sleeping
end