Module: Stackprofiler

Defined in:
lib/stackprofiler.rb,
lib/stackprofiler/utils.rb,
lib/stackprofiler/web_ui.rb,
lib/stackprofiler/version.rb,
lib/stackprofiler/middleware.rb,
lib/stackprofiler/data_collector.rb,
lib/stackprofiler/filters/js_tree.rb,
lib/stackprofiler/run_data_source.rb,
lib/stackprofiler/filters/build_tree.rb,
lib/stackprofiler/filters/gem_removal.rb,
lib/stackprofiler/filters/rebase_stack.rb,
lib/stackprofiler/filters/compress_tree.rb,
lib/stackprofiler/filters/frame_regex_removal.rb,
lib/stackprofiler/filters/quick_method_removal.rb

Defined Under Namespace

Modules: Filter Classes: DataCollector, Middleware, Run, RunDataSource, WebUI

Constant Summary collapse

VERSION =
'0.0.2'

Class Method Summary collapse

Class Method Details

.profileObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/stackprofiler/utils.rb', line 18

def profile
  # todo: pass through options perhaps?
  profile = StackProf.run(mode: :wall, raw: true) { yield }
  # todo: remove terrible hard-coded url
  url = URI::parse 'http://localhost:9292/__stackprofiler/receive'
  headers = {'Content-Type' => 'application/json'}
  req = Net::HTTP::Post.new(url.to_s, headers)
  req.body = Oj.dump profile
  response = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
end