-
Notifications
You must be signed in to change notification settings - Fork 407
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
Parse meaningful data from stored results #139
Comments
👍 I am in a similar situation where it would be helpful to get profiler information (and flamegraphs) for an mobile API that I'm working on. |
+1, I'd like to profile backend for an angular application. All the interaction between frontend and rails is in JSON format and I'd like to parse the mp_timers_* files. |
@silasb @YoranBrondsema
|
I would love to see some way to get more details on API requests that we feed into a Javascript front-end (i.e., Ember/Angular). I've seen https://github.com/dejan/rails_panel, which does something like this via a chrome extension, which is an interesting approach. |
You should be able to inject it just fine: at the moment this is the extra script that is added:
Each time we change js versions change... but overall once you include this ... all new requests to API will be added. The version stuff is there to break caching you could simply put something random there every time you build. |
Just wanted to say that the javascript snippet @SamSaffron presented works perfectly for me. Might be useful to actually have this mentioned in the https://github.com/MiniProfiler/rack-mini-profiler#using-in-spa-applications section? |
cool, yeah a PR to improve doco is welcome! |
@SamSaffron #227 hopefully does the trick for the doc update. |
@SamSaffron sorry to bring it up again after a long time, but I don't understand |
Maybe something you could use as a reference: I use the following implementation to view my profiling data: https://github.com/kbrock/cli_mini_profiler I run with something like:
Maybe you could steal some ideas from there. Some of the aggregates are not perfect, so please let me know if you find any issues. |
Apologies as well for adding more conversation to an issue that might be considered closed. I'm having trouble with the |
@charlie-wasp we're you ever able to figure out how to use |
@jwpari I'm afraid no, I just gave up on it :( |
Although admittedly a little messy, I was able to get my app to serve an html page with the script so that I could look at API requests # config/initializers/mini_profiler.rb
Rails.application.routes.append do
mini_profiler = Rack::MiniProfiler.new(Rails.application)
get '/profiler' => ->(env) {
[200, {}, [<<-BODY.strip_heredoc]]
<html>
<head>
</head>
<body>
#{mini_profiler.get_profile_script(env)}
</body>
</html>
BODY
}
end |
FWIW, I just did this from my rails console and copypasta'ed it into my ember app:
|
In Rails 6 (yeah, I know) the javascript was being rendered as plain text. What got me going was @turboladen's solution, put in the header of the application layout file, and then rendered safely.
Oddly, the javascript that was being rendered at the bottom of the page went away. I didn't expect that but I'm not going to look a gift horse in the mouth. If someone knows off the top of their head where the javascript is being injected, I'll take a look making a PR for something not-so-hacky. It wasn't obvious to me. |
Any insight into making this work with CORS? My API server is different from my web server and the POST to /results fails the pre-flight check. I've tried the following but had no luck: allow do
origins Rails.application.config.web_client_domain
resource '/mini-profiler-resources/results', methods: [:post, :get]
end |
As of #396, you no longer need to manually inject MP script tag into a page or create a custom route because MP now ships with a special route at |
Anyone know how I can get this to work in prod? |
/rack-mini-profiler/requests is empty in staging environment |
FWIW/ I store my data in redis, it makes it much easier for other tools to fetch from there. |
I still don't understand how #396 is supposed to work when it has an empty head and body tag. |
Hi,
I have an Ember.js application backed by a Rails API. Since the
index.html
is generated by the front-end, MiniProfiler cannot inject itself onto the page. However, I would still like to use its results.It seems the output in
/tmp/miniprofiler/*
cannot be used without parsing it. Is there a way to store the same output that it prints in HTML in a file? Then I can just cURL to actions in my controller and view a meaningful MiniProfiler report.The text was updated successfully, but these errors were encountered: