Module: Instrumentation

Defined in:
lib/instrumentation.rb,
lib/instrumentation/view.rb,
lib/instrumentation/memory.rb,
lib/instrumentation/report.rb,
lib/instrumentation/version.rb,
lib/instrumentation/rack_app.rb,
lib/instrumentation/webserver.rb,
lib/instrumentation/load_average.rb,
lib/instrumentation/bounded_array.rb

Overview

Instrumentation

Start a server by calling:

Instrumentation.start_server(Process.pid)

By default the server is started on localhost:8080

Defined Under Namespace

Classes: BoundedArray, LoadAverage, Memory, RackApp, Report, View, Webserver

Constant Summary collapse

VERSION =
'0.1.3'.freeze

Class Method Summary collapse

Class Method Details

.rootObject



32
33
34
# File 'lib/instrumentation.rb', line 32

def root
  Pathname.new(__FILE__).join('..', '..')
end

.start_server(pid:, port: 8080) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/instrumentation.rb', line 17

def start_server(pid:, port: 8080)
  report = Report.new(pid)
  app = RackApp.new(report)
  server = Webserver.new

  report.start
  server.run(app, port: port)

  [server, report].map(&:join)
rescue Interrupt => _
  print "\n=> Shutting down instrumentation.\n"
  report.shutdown
  server.stop
end