From 10dd7afde551594f403a1213448df2d2a3ab078c Mon Sep 17 00:00:00 2001 From: Nate Berkopec Date: Tue, 18 Apr 2023 07:51:42 +0900 Subject: [PATCH] Add documentation --- README.md | 2 +- lib/mini_profiler.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d0fff3c9..bf3f96c0 100644 --- a/README.md +++ b/README.md @@ -178,7 +178,7 @@ export RACK_MINI_PROFILER_PATCH_NET_HTTP="false" To generate [flamegraphs](http://samsaffron.com/archive/2013/03/19/flame-graphs-in-ruby-miniprofiler), add the [**stackprof**](https://rubygems.org/gems/stackprof) gem to your Gemfile. -Then, to view the flamegraph as a direct HTML response from your request, just visit any page in your app with `?pp=flamegraph` appended to the URL. +Then, to view the flamegraph as a direct HTML response from your request, just visit any page in your app with `?pp=flamegraph` appended to the URL, or add the header `X-Rack-Mini-Profiler` to the request with the value `flamegraph`. Conversely, if you want your regular response instead (which is specially useful for JSON and/or XHR requests), just append the `?pp=async-flamegraph` parameter to your request/fetch URL; the request will then return as normal, and the flamegraph data will be stored for later *async* viewing, both for this request and for all subsequent requests made by this page (based on the `REFERER` header). For viewing these async flamegraphs, use the 'flamegraph' link that will appear inside the MiniProfiler UI for these requests. diff --git a/lib/mini_profiler.rb b/lib/mini_profiler.rb index 6f817c62..10ad2098 100644 --- a/lib/mini_profiler.rb +++ b/lib/mini_profiler.rb @@ -702,6 +702,8 @@ def help(client_settings, env) #{make_link "flamegraph_embed", env} : a graph representing sampled activity (requires the stackprof gem), embedded resources for use on an intranet. #{make_link "trace-exceptions", env} : will return all the spots where your application raises exceptions #{make_link "analyze-memory", env} : will perform basic memory analysis of heap + + All features can also be accessed by adding the X-Rack-Mini-Profiler header to the request, with any of the values above (e.g. 'X-Rack-Mini-Profiler: flamegraph')