class Fintop::ThreadsData
Container class for data gathered from a Finagle server’s thread-dump endpoint.
Attributes
num_non_daemon[R]
num_runnable[R]
num_threads[R]
num_timed_waiting[R]
num_waiting[R]
Public Class Methods
new(admin_port)
click to toggle source
Initialize a ThreadsData
object for a Finagle server’s on a given port’s “/admin/threads” endpoint.
@param admin_port [Fixnum]
# File lib/fintop/threads.rb, line 18 def initialize(admin_port) json_str = Net::HTTP.get( URI.parse("http://localhost:#{admin_port}/admin/threads") ) @threads = JSON.parse(json_str)['threads'].to_a @num_threads = @threads.size @num_runnable = @threads.count { |tid, thread| thread['state'] == 'RUNNABLE' } @num_waiting = @threads.count { |tid, thread| thread['state'] == 'WAITING' } @num_timed_waiting = @threads.count { |tid, thread| thread['state'] == 'TIMED_WAITING' } @num_non_daemon = @threads.count { |tid, thread| thread['daemon'] == false } end