New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FEATURE: Introduce pp=async-flamegraph
for asynchronous flamegraphs
#494
FEATURE: Introduce pp=async-flamegraph
for asynchronous flamegraphs
#494
Conversation
Using `?pp=async-flamegraph` causes the flamegraph data to be stored in the page_struct, and made available via a link in the mini_profiler UI. Flamegraph data will also be recorded and stored for all AJAX requests with `?pp=async-flamegraph` in the `Referer` header. This is useful in a few situations: - You want to view flamegraphs for AJAX requests made by a Javascript application. By supplying `pp=async-flamegraph`, flamegraph links for every AJAX request will be made available in the mini-profiler UI. - You want to see the HTML result of a request, and view the flamegraph later. The existing `?pp=flamegraph` option hides the true output. - You are performing the request via a tool like `curl`, and would like to view the flamegraph later in the browser (you can extract the X-MiniProfiler-Ids header from the response, then view flamegraph in the browser)
This updates the preview_theme_id preservation logic to use more recent, robust, browser APIs. It also adds support for preserving the `?pp=async-flamegraph` parameter which is proposed in MiniProfiler/rack-mini-profiler#494
I see what you did here! looks great. Some feedback
@OsamaSayegh can you have a look as well? |
Yeah I think we want to make the parameter sticky for internal links. I made a draft for that in discourse/discourse#12863 Agreed on 2 & 3 - will look at those things tomorrow.
Sounds cool! How do you imagine the UX working here? I guess flamegraphs could be added to the sampling feature, although it is quite a lot of data so we probably wouldn't want to be shipping it to other sites like we do with the other sampled data. |
I guess I would start backwards :) My use case is:
Even though I can get a flamegraph today for I am thinking I would use a special route to "enable collection" for a path. Then I would head to another page to see all the current collected results. A "list" UI is generally useful anyway for the REFERER solution cause it allows you to easily dig through history. I would say that data forwarding (like we do for sampling) may be a v3 kind of feature. (list UI and strategic route based collection can also be a v2 thing, it should not hold up this PR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks excellent to me 👌 Just one minor comment/question.
Codecov Report
@@ Coverage Diff @@
## master #494 +/- ##
==========================================
- Coverage 88.70% 87.59% -1.11%
==========================================
Files 18 18
Lines 1257 1274 +17
==========================================
+ Hits 1115 1116 +1
- Misses 142 158 +16
Continue to review full report at Codecov.
|
All we need for the `results` route is a boolean. The `/flamegraph` route takes care of the actual flamegraph data
Thanks @SamSaffron and @OsamaSayegh. Updated based on your comments, now with tests, and updates to the README/CHANGELOG. |
Ok, I'm merging this in, thanks @davidtaylorhq ❤️ We will need @SamSaffron to push a new version on rubygems because I don't think I have push access there. |
This updates the preview_theme_id preservation logic to use more recent, robust, browser APIs. It also adds support for preserving the `?pp=async-flamegraph` parameter which is proposed in MiniProfiler/rack-mini-profiler#494
Using
?pp=async-flamegraph
causes the flamegraph data to be placed in long-term storage, and made available via a link in the mini_profiler UI. Flamegraph data will also be recorded and stored for all AJAX requests with?pp=async-flamegraph
in theReferer
header. This is useful in a few situations:You want to view flamegraphs for AJAX requests made by a Javascript application. By supplying
pp=async-flamegraph
, flamegraph links for every AJAX request will be made available in the mini-profiler UI.You want to see the HTML result of a request, and view the flamegraph later. The existing
?pp=flamegraph
option hides the true output.You are performing the request via a tool like
curl
, and would like to view the flamegraph later in the browser (you can extract the X-MiniProfiler-Ids header from the response, then view flamegraph in the browser)When the
pp=async-flamegraph
parameter is supplied, a new "flamegraph" link is added to the UI:Clicking the link will take you to a URL like
/mini-profiler-resources/flamegraph?id=t0x70kt7hy3cmitx7adx
, which displays the flamegraph UI.