Rails Profiler in Chrome and Firefox DevTools.

The extension adds a Rails Profiler panel to DevTools. It lists the profiled requests of the page you are browsing, page loads and fetch or XHR calls alike, and shows the full profile of each one next to the page. On a front end or a single page app, where Rails renders no toolbar, it can also draw its own profiler bar at the bottom of the page.

Add to ChromeAdd to FirefoxFrom the Chrome Web Store (Chrome, Edge and Brave) or Firefox Add-ons (Firefox 128 or later, on desktop).

A viewer, not a second dashboard

The panel does not reimplement the profiler. When you select a request, it loads the dashboard served by your own Rails app, <base URL>/_profiler/profiles/<token>?embed=true, in an iframe. What you see in DevTools is the dashboard of the gem you installed, tab for tab, so it always matches that gem's version.

On the profiler origin, the extension wraps fetch and XMLHttpRequest and notes every response that carries an X-Profiler-Token header. It also reads the token the gem renders into the toolbar of HTML pages, and the response headers of pages that have no toolbar. The service worker keeps the 100 most recent requests for the browser session. The panel shows their method, URL, status, duration and time, newest first, with a filter, and opens the first request by itself when nothing is selected.

A profile stays live while it is open: if the gem saves it again, for example when a background job finishes after the page, the panel reloads it. It checks often at first, then every 30 seconds, and stops after 10 minutes without a new save.

The Rails Profiler panel. On the left, the six requests of the page with their status and duration: GET /api/n_plus_one, GET /api/raise_error answered 500, /api/cache_intensive, /api/slow_query, /api/users three times and the home page. On the right, the profile of /api/n_plus_one open on its Database tab: 26 queries, a potential N+1 warning for one pattern repeated 25 times, and the repeated author queries flagged N+1.
The panel, here with an N+1 query detected on a request. Screenshot from the extension's repository, taken on the gem's test app.

A profiler bar for front ends and single page apps

The gem puts its toolbar into the HTML pages Rails renders. A separate front end or a single page app calling a Rails API gets no such page: only the API responses carry X-Profiler-Token. For that case the extension draws its own bar across the bottom of the page, without opening DevTools. It uses the gem's toolbar palette, value for value, in dark and light, and follows the theme you chose in the gem on that origin, else the system's.

The bar is the only thing the extension adds to a page, and only on the origins you listed in its settings and granted access to. So for a front end served from its own origin, for example its own dev server, add that origin in the settings. The bar overlays the last 32 px of the page and reserves no space; it reads its numbers from the gem's toolbar route and stores none of the details.

The extension's bar expanded at the bottom of the test app's front end page, on its API calls tab. Nine requests are listed with method, path, status, duration and SQL and HTTP totals: GET /api/raise_error answered 500, POST /jobs/scheduled started 1 job, POST /jobs/failing started 1 failed job, POST /jobs/nested started 2 jobs, GET /api/external_http_bodies made 3 HTTP calls, GET /api/n_plus_one ran 26 SQL queries. Under the list, the collapsed line shows a red dot, 9 calls, 1 error and Jobs 4 with 1 failed.
The expanded bar on a single page app: every API call of the page, with the number of jobs each one started, and the All, Errors and Slow filters. Taken on the gem's test app.
The bar's Outbound HTTP tab: seven calls from the Rails app to jsonplaceholder.typicode.com, with method, status and duration: a PUT, a PATCH and a POST made by GET /api/external_http_bodies, and four GETs made by GET /api/external_http, one of them a 404 flagged as an error. Each row names the API request it came from.
The Outbound HTTP tab: what the Rails app called while serving the page's requests.
The bar's Jobs tab, over the test app's front end page. Four jobs from nine requests: ScheduledDigestJob on the mailers queue is scheduled, FailingJob on the default queue failed after 121 ms and is flagged failed, NestedParentJob is done after 1020 ms and NestedChildJob, indented under it, is done after 510 ms. Each row names the API request it came from, and the collapsed line shows Jobs 4 with 1 failed.
The Jobs tab: a scheduled job, a failed one, and a job with the job it queued. Taken on the gem's test app.
A failed job opened in the bar: FailingJob on the default queue, failed after 121 ms on its first attempt, from POST /jobs/failing. Its error, RuntimeError: Simulated job failure for profiler testing, with the application frame of its backtrace, its argument 42, its job id, and the outgoing GET to jsonplaceholder.typicode.com/posts/42 that answered 200.
A failed job opened in place: its error and backtrace, its arguments as the gem masked them, and the outgoing call it made before failing.
An outbound call opened in the bar: POST to jsonplaceholder.typicode.com/posts answered 201 in 137 ms, from GET /api/external_http_bodies. Its full URL, request headers, the JSON request body, and response headers.
An outbound call opened in place, with its headers and bodies as the gem recorded and redacted them.

Access to the origins you choose, nothing else

Installed, the extension has access to no website at all. It works on the origins you grant, one at a time: the scheme, host and port of each profiler URL you set in its settings, by default http://localhost:3000.

  1. You open the settings page (it opens by itself after install, or from the gear in the panel) and set the protocol, host and port of your Rails app.
  2. Save stores the URL, then asks the browser for access to that origin alone, for example http://localhost:3000/*. You accept or refuse the prompt. Firefox match patterns cannot carry a port, so there the access covers every port of that host; the extension still acts only on the exact origin you listed.
  3. Once access is granted, the extension registers its scripts for that origin. There it adds nothing to the page but its own bar, on pages without the gem's toolbar. On every other site it injects nothing and reads nothing.
  4. Whenever it starts, the URL changes or a permission is added, the background script (a service worker in Chrome) removes any other site access the extension holds. Removing access never needs a prompt.

This is a deliberate change: versions 1.0.2 and earlier requested access to every site. After an update from one of them, that broad access is removed automatically and the settings page opens, so you save the profiler URL once and accept the prompt. If you refuse it, the URL is saved but profiling stays off until you save again. You can withdraw the access at any time under "Site access" on the extension's details page.

One consequence to know: only pages of that exact origin are profiled. A front end on its own dev server, another port, or 127.0.0.1 instead of localhost is a different origin, so set the profiler URL to the origin of the pages you browse.

The extension's settings page, Target application section: a protocol menu set to http, a host field set to localhost, a port field set to 3000, the resulting URL http://localhost:3000, a message saying access was granted, and the Test, Reset to default and Save buttons, above the Other origins section.
The settings page, where you set the profiler URL. The value is saved in chrome.storage.sync.

What the manifest asks for

storage
Saves the profiler URL (chrome.storage.sync) and keeps the request list when the browser stops the background script, a service worker in Chrome (chrome.storage.session).
scripting
Registers the content scripts, the in-page bar included unless you turn it off, for the profiler origin only. They are not declared in the manifest, so nothing is injected anywhere else.
webRequest
Observes, never blocks or changes, the main frame response of a page of the profiler origin, and reads only its X-Profiler-Token header. It catches the pages the gem profiles without a toolbar: streamed HTML, send_file downloads, JSON or PDF opened in a tab.
optional_host_permissions
Declares http://*/* and https://*/* as optional only. Nothing is granted at install; the settings page requests the origin of the profiler URL and nothing else.

Requirements

Install

  1. Open the extension's page on the Chrome Web Store and clickAdd to Chrome.
  2. The settings page opens: check the profiler URL, click Save and accept the browser prompt that asks access to that site.
  3. Reload the tab you want to profile, open DevTools (F12) and pick the Rails Profiler tab.

On Firefox, open the extension's page on Firefox Add-ons and clickAdd to Firefox, then follow the same steps. If the settings page does not open by itself after install, open it from the gear in the panel.

If no requests appear