13

How do we get rack-mini-profiler to show in a rails json api? I believe this was asked here: How to profile a rails controller that returns a json response with rack-mini-profiler? but the only answer is to try it out on an html file. How do we see the profiler measurements on a json page?

Community
  • 1
  • 1
user1848902
  • 165
  • 6
  • 1
    Rack-mini-profiler save the data when not displayed. Go to your profiled JSON page and then hit a HTML page, results shown will the the JSON page ones. – tildedash Apr 09 '17 at 21:44
  • This doesn't seem to be possible yet. See: https://github.com/MiniProfiler/rack-mini-profiler/issues/243, which is an issue tracking it. – xji May 27 '19 at 14:32
  • Not sure if this helps but I've noticed that when I test API requests originating from a rendered view, the profiler adds the API JSON to that page's JSON and shows all of it in the browser. I was able at some point to write a test that was checking the client side response time of some API calls, I only ditched it because Capybara gets flaky with complex DOM sometimes. – Nick M Apr 07 '21 at 04:57

1 Answers1

0

Rack Mini Profiler shows results by injecting its JavaScript on an HTML page.

So you will need to:

  • hit that API endpoint (either in a browser or in the command line)
  • go to a page that is rendered in HTML
  • Look at the stack of results
  • Pick the result that matches your API request

There you can look at SQL queries and all.

Dorian
  • 7,749
  • 4
  • 38
  • 57