How to profile a non-html Rails 4?


#1

Hi,

I’m working on a Rails 4.1.rc1 app. It’s an API that renders only JSON resources. I’d like to use rack-mini-profiler to look at some portions of code.

Is it the right tool? How to do this without an HTML page to inject results into?

Thanks.


#2

Should work fine, but you will need some custom work grabbing the results, it includes the profile guid in headers for each req, you can harvest them using json calls later.


#3

It seems doable.

Do you have an example for how to do this harvest using JSON ?

Thanks


#4

In the meantime, requesting the API with the ?pp=flamegraph gives back the flamegraph HTML page for the corresponding API endpoint, witch is really useful.


#5

if rack mini profiler can’t display the results, it will collect them until it can on the next HTML page. So, the solution that I am using is to:

make the JSON request and
then hit an HTML page of my choice.
The results will appear, along with the most recent HTML profile.


#6

I do have the same question. After adding the gem, when I call the API, I see only my JSON data. How to see the profile data?


#7

Do you mean the HTML of the same service? What if my service doesn’t have a HTML page at all?

Thank you


#8

When I call the API from Postman, I see below header. But they are encrypted. How to decrypt them?

X-MiniProfiler-Ids →[“mr2z8e9jblj8jwvc2z0x”,“ba8z993edebbck9n9yq2”,“efh7dt8exlklhhwkf07r”,“n8al9x4ew8q65any4nmd”,“xl7djpj3hcyoy9pjurxn”,“ie7c0h9bovc9j9t7uwlj”,“frrcwq4460qzyqmy7h5m”,“ndrxyw0n4ws85izuiokl”,“yrz1u6qe4s8j02ghubmd”,“fr744fd6wf0zbsgu3apt”,“mjvs9mobimgpwejy6fwp”,“e8v8pjbcuv6w8akrs9mv”,“jdwpcb29epn4yqq4gw4y”,“3yro1leeqgebm0zcgfna”,“ljlhgselyz92d9ufuwvd”,“1sycn9a67jp8g4g96fv3”,“z46plkd77b83ihprincq”,“k70bd6u8tlv1l0qtafvk”,“5f5fy784n2oa6r084xw3”,“r8kei0qj1w0v7mhlegkt”]

X-MiniProfiler-Original-Cache-Control →max-age=0, private, must-revalidate