Class: Leafy::Rack::ThreadDumpWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/leafy/rack/thread_dump.rb

Instance Method Summary collapse

Constructor Details

#initializeThreadDumpWriter

Returns a new instance of ThreadDumpWriter.



9
10
11
12
13
14
15
16
# File 'lib/leafy/rack/thread_dump.rb', line 9

def initialize
  begin
    # Some PaaS like Google App Engine blacklist java.lang.managament
    @threads = com.codahale.metrics.jvm.ThreadDump.new(ManagementFactory.getThreadMXBean());
  rescue LoadError
    # we won't be able to provide thread dump
  end
end

Instance Method Details

#to_textObject



18
19
20
21
22
23
24
25
# File 'lib/leafy/rack/thread_dump.rb', line 18

def to_text
  if @threads
    # TODO make this stream
    output = java.io.ByteArrayOutputStream.new
    @threads.dump(output)
    output.to_s
  end
end