To enable the snapshots transporter, you need to provide a destination URL to the snapshots_transport_destination_url config, and a secure key to the snapshots_transport_auth_key config (will be used for authorization). The main use-case of the transporter is to allow the aggregation of snapshots from multiple applications/sources in a single place. Mini Profiler can be configured so that it sends snapshots over HTTP using the snapshots transporter. the snapshot whose request took the least time compared to other snapshots). When snapshots reach the configured limit, Mini Profiler will save a new snapshot only if it's worse than at least one of the existing snapshots and delete the best one (i.e. Mini Profiler will keep a maximum of 1000 snapshots by default, and you can change that via the snapshots_limit config. From there, you can click on a snapshot's ID to see the snapshot with all the performance metrics that were collected.Īccess to the snapshots page is restricted to only those who can see the speed badge on their own requests, see the section below this one about access control. Clicking on a group will display the snapshots of that group sorted from worst to best. Snapshots grouped by HTTP method and path of the request, and if your application is a Rails app, Mini Profiler will try to convert the path to controller#action and group by that instead of request path. The worst snapshot in a group is defined as the snapshot whose request took longer than all of the snapshots in the same group. You'll see on that page a table where each row represents a group of snapshots with the duration of the worst snapshot in that group. Additionally, if profiling is enabled for a request that later finishes with a non-2xx status code, Mini Profiler will discard the snapshot and not save it (this behavior may change in the future).Īfter enabling snapshots sampling, you can see the snapshots that have been collected at /mini-profiler-resources/snapshots (or if you changed the base_url_path config, substitute mini-profiler-resources with your value of the config).
Mini Profiler will exclude requests that are made to skipped paths (see skip_paths config below) from being sampled. The larger the value is, the less frequently requests are profiled. To turn this feature on, set the snapshot_every_n_requests config to a value larger than 0. It works by enabling invisible profiling on one request every N requests, and saving the performance metrics that are collected during the request (a.k.a snapshot of the request) so that they can be viewed later. Mini Profiler ships with a feature to help detect those rare conditions and fix them. In a complex web application, it's possible for a request to trigger rare conditions that result in poor performance. Use ?pp=analyze-memory to report on ObjectSpace statistics.Use ?pp=profile-gc to report on Garbage Collection statistics.There are two additional pp options that can be used to analyze memory which do not require the memory_profiler gem The allow/ignore patterns will be treated as regular expressions.Įxample: ?pp=profile-memory&memory_profiler_allow_files=active_record|app memory_profiler_top - number of results per section (defaults to 50).memory_profiler_ignore_files - filename pattern to exclude (default is no exclusions).memory_profiler_allow_files - filename pattern to include (default is all files).Which will show allocations broken down by gem, file location, and class and will also highlight String allocations.Īdd ?pp=profile-memory to the URL of any request while Rack::MiniProfiler is enabled to generate the report.Īdditional query parameters can be used to filter the results. Memory allocations can be measured (using the memory_profiler gem) Mini Profiler's methods that are responsible for generating the timings data out of the flamegraph. Note: Mini Profiler will not record SQL timings for a request if it asks for a flamegraph. For viewing these async flamegraphs, use the 'flamegraph' link that will appear inside the MiniProfiler UI for these requests. 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.Ĭonversely, 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). To generate flamegraphs, add the stackprof gem to your Gemfile. Export RACK_MINI_PROFILER_PATCH= "pg,mongoid " # or export RACK_MINI_PROFILER_PATCH= "false " # initializers/rack_profiler.rb: SqlPatches.patch %w(mongo) Flamegraphs