rails_mini_profiler 0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +29 -111
- data/Rakefile +18 -0
- data/app/{javascript/images → assets/images/rails_mini_profiler}/bookmark.svg +0 -0
- data/app/{javascript/images → assets/images/rails_mini_profiler}/chart.svg +0 -0
- data/app/{javascript/images → assets/images/rails_mini_profiler}/delete.svg +0 -0
- data/app/{javascript/images → assets/images/rails_mini_profiler}/graph.svg +0 -0
- data/app/{javascript/images → assets/images/rails_mini_profiler}/logo.svg +0 -0
- data/app/{javascript/images → assets/images/rails_mini_profiler}/logo_variant.svg +2 -2
- data/app/assets/images/rails_mini_profiler/search.svg +10 -0
- data/app/{javascript/images → assets/images/rails_mini_profiler}/setting.svg +0 -0
- data/app/{javascript/images → assets/images/rails_mini_profiler}/show.svg +0 -0
- data/app/assets/javascripts/rails_mini_profiler.js +76 -1
- data/app/assets/stylesheets/rails_mini_profiler/application.css +149 -1
- data/app/assets/stylesheets/rails_mini_profiler/flamegraph.css +14 -0
- data/app/{javascript/stylesheets/flashes.scss → assets/stylesheets/rails_mini_profiler/flashes.css} +5 -3
- data/app/{javascript/stylesheets/navbar.scss → assets/stylesheets/rails_mini_profiler/navbar.css} +14 -8
- data/app/assets/stylesheets/rails_mini_profiler/profiled_requests.css +180 -0
- data/app/{javascript/stylesheets/traces.scss → assets/stylesheets/rails_mini_profiler/traces.css} +22 -17
- data/app/controllers/rails_mini_profiler/application_controller.rb +4 -9
- data/app/controllers/rails_mini_profiler/profiled_requests_controller.rb +10 -23
- data/app/helpers/rails_mini_profiler/application_helper.rb +0 -11
- data/app/models/rails_mini_profiler/application_record.rb +1 -1
- data/app/models/rails_mini_profiler/controller_trace.rb +3 -7
- data/app/models/rails_mini_profiler/flamegraph.rb +0 -4
- data/app/models/rails_mini_profiler/instantiation_trace.rb +3 -7
- data/app/models/rails_mini_profiler/profiled_request.rb +15 -21
- data/app/models/rails_mini_profiler/render_partial_trace.rb +3 -7
- data/app/models/rails_mini_profiler/render_template_trace.rb +3 -7
- data/app/models/rails_mini_profiler/rmp_trace.rb +3 -7
- data/app/models/rails_mini_profiler/sequel_trace.rb +3 -7
- data/app/models/rails_mini_profiler/trace.rb +3 -7
- data/app/presenters/rails_mini_profiler/profiled_request_presenter.rb +15 -8
- data/app/views/layouts/rails_mini_profiler/application.html.erb +12 -1
- data/app/views/layouts/rails_mini_profiler/flamegraph.html.erb +8 -1
- data/app/views/rails_mini_profiler/badge.html.erb +2 -2
- data/app/views/rails_mini_profiler/profiled_requests/index.html.erb +58 -8
- data/app/views/rails_mini_profiler/profiled_requests/show.html.erb +1 -1
- data/app/views/rails_mini_profiler/shared/_navbar.html.erb +1 -1
- data/db/migrate/20210621185018_create_rmp.rb +6 -8
- data/lib/generators/rails_mini_profiler/install_generator.rb +0 -24
- data/lib/generators/rails_mini_profiler/templates/rails_mini_profiler.rb.erb +7 -23
- data/lib/rails_mini_profiler/badge.rb +1 -23
- data/lib/rails_mini_profiler/configuration.rb +4 -28
- data/lib/rails_mini_profiler/engine.rb +4 -15
- data/lib/rails_mini_profiler/errors.rb +8 -0
- data/lib/rails_mini_profiler/guard.rb +7 -18
- data/lib/rails_mini_profiler/logger.rb +0 -5
- data/lib/rails_mini_profiler/middleware.rb +4 -4
- data/lib/rails_mini_profiler/models/base_model.rb +0 -5
- data/lib/rails_mini_profiler/models/trace.rb +9 -0
- data/lib/rails_mini_profiler/redirect.rb +1 -9
- data/lib/rails_mini_profiler/request_context.rb +7 -31
- data/lib/rails_mini_profiler/request_wrapper.rb +8 -44
- data/lib/rails_mini_profiler/storage.rb +29 -0
- data/lib/rails_mini_profiler/tracers.rb +85 -0
- data/lib/rails_mini_profiler/version.rb +1 -1
- data/lib/rails_mini_profiler.rb +9 -33
- metadata +30 -127
- data/LICENSE +0 -20
- data/app/javascript/images/check.svg +0 -3
- data/app/javascript/images/chevron.svg +0 -3
- data/app/javascript/images/filter.svg +0 -1
- data/app/javascript/images/search.svg +0 -9
- data/app/javascript/js/checklist_controller.js +0 -48
- data/app/javascript/js/enable_controller.js +0 -24
- data/app/javascript/js/filter_controller.js +0 -44
- data/app/javascript/js/search_controller.js +0 -18
- data/app/javascript/js/select_controller.js +0 -47
- data/app/javascript/packs/rails-mini-profiler.js +0 -88
- data/app/javascript/stylesheets/components/page_header/page_header.scss +0 -3
- data/app/javascript/stylesheets/components/pagination.scss +0 -55
- data/app/javascript/stylesheets/components/profiled_request_table/placeholder.scss +0 -33
- data/app/javascript/stylesheets/components/profiled_request_table/profiled_request_table.scss +0 -179
- data/app/javascript/stylesheets/flamegraph.scss +0 -10
- data/app/javascript/stylesheets/profiled_requests.scss +0 -89
- data/app/javascript/stylesheets/rails-mini-profiler.scss +0 -205
- data/app/search/rails_mini_profiler/base_search.rb +0 -67
- data/app/search/rails_mini_profiler/profiled_request_search.rb +0 -34
- data/app/views/models/_flamegraph.json.jb +0 -3
- data/app/views/models/_profiled_request.jb +0 -3
- data/app/views/models/_trace.jb +0 -3
- data/app/views/rails_mini_profiler/flamegraphs/show.json.jb +0 -3
- data/app/views/rails_mini_profiler/profiled_requests/index.json.jb +0 -3
- data/app/views/rails_mini_profiler/profiled_requests/shared/header/_header.erb +0 -20
- data/app/views/rails_mini_profiler/profiled_requests/shared/table/_placeholder.erb +0 -12
- data/app/views/rails_mini_profiler/profiled_requests/shared/table/_table.erb +0 -14
- data/app/views/rails_mini_profiler/profiled_requests/shared/table/_table_head.erb +0 -125
- data/app/views/rails_mini_profiler/profiled_requests/shared/table/_table_row.erb +0 -21
- data/app/views/rails_mini_profiler/profiled_requests/show.json.jb +0 -5
- data/app/views/rails_mini_profiler/shared/_head.erb +0 -13
- data/lib/generators/rails_mini_profiler/templates/rails_mini_profiler.js.erb +0 -13
- data/lib/rails_mini_profiler/configuration/storage.rb +0 -47
- data/lib/rails_mini_profiler/configuration/user_interface.rb +0 -48
- data/lib/rails_mini_profiler/tracing/controller_tracer.rb +0 -15
- data/lib/rails_mini_profiler/tracing/null_trace.rb +0 -7
- data/lib/rails_mini_profiler/tracing/sequel_tracer.rb +0 -37
- data/lib/rails_mini_profiler/tracing/sequel_tracker.rb +0 -37
- data/lib/rails_mini_profiler/tracing/subscriptions.rb +0 -34
- data/lib/rails_mini_profiler/tracing/trace.rb +0 -45
- data/lib/rails_mini_profiler/tracing/trace_factory.rb +0 -37
- data/lib/rails_mini_profiler/tracing/tracer.rb +0 -31
- data/lib/rails_mini_profiler/tracing/view_tracer.rb +0 -12
- data/lib/rails_mini_profiler/tracing.rb +0 -11
- data/public/rails_mini_profiler/speedscope/LICENSE +0 -21
- data/public/rails_mini_profiler/speedscope/demangle-cpp.1768f4cc.js +0 -4
- data/public/rails_mini_profiler/speedscope/demangle-cpp.1768f4cc.js.map +0 -1
- data/public/rails_mini_profiler/speedscope/favicon-16x16.f74b3187.png +0 -0
- data/public/rails_mini_profiler/speedscope/favicon-32x32.bc503437.png +0 -0
- data/public/rails_mini_profiler/speedscope/file-format-schema.json +0 -324
- data/public/rails_mini_profiler/speedscope/import.e3a73ef4.js +0 -117
- data/public/rails_mini_profiler/speedscope/import.e3a73ef4.js.map +0 -1
- data/public/rails_mini_profiler/speedscope/index.html +0 -2
- data/public/rails_mini_profiler/speedscope/release.txt +0 -3
- data/public/rails_mini_profiler/speedscope/reset.8c46b7a1.css +0 -2
- data/public/rails_mini_profiler/speedscope/reset.8c46b7a1.css.map +0 -1
- data/public/rails_mini_profiler/speedscope/source-map.438fa06b.js +0 -24
- data/public/rails_mini_profiler/speedscope/source-map.438fa06b.js.map +0 -1
- data/public/rails_mini_profiler/speedscope/speedscope.026f36b0.js +0 -200
- data/public/rails_mini_profiler/speedscope/speedscope.026f36b0.js.map +0 -1
- data/vendor/assets/images/bookmark.svg +0 -10
- data/vendor/assets/images/chart.svg +0 -12
- data/vendor/assets/images/check.svg +0 -3
- data/vendor/assets/images/chevron.svg +0 -3
- data/vendor/assets/images/delete.svg +0 -9
- data/vendor/assets/images/filter.svg +0 -1
- data/vendor/assets/images/graph.svg +0 -11
- data/vendor/assets/images/logo.svg +0 -18
- data/vendor/assets/images/logo_variant.svg +0 -32
- data/vendor/assets/images/search.svg +0 -9
- data/vendor/assets/images/setting.svg +0 -10
- data/vendor/assets/images/show.svg +0 -11
- data/vendor/assets/javascripts/rails-mini-profiler.css +0 -1
- data/vendor/assets/javascripts/rails-mini-profiler.js +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5b1f043e04e0f4aaf67b7cfe22be413aa689e51553c3e30e535b2a828d5abde2
|
|
4
|
+
data.tar.gz: '028d6a1d92f6d66552ccf5f7ea9d1c622d15551ba16977c53b773041fd48464c'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4722b94b458742b5f0c3f3ebe12c119054f053f9a4c783748e5e72686f5676de3fdc7ea5ff9c7aa1bc3872e4ed1d139934aeeb7f653ab40a4818d11b268b85ef
|
|
7
|
+
data.tar.gz: '0958d98854d3df4c1129a2aef7a85dbf0053770f6c761b7901bf3e121acbb2d1116308d419364ce5528b1b8458d68368bb6f32938966b5a35215c45fe8cd2872'
|
data/README.md
CHANGED
|
@@ -6,42 +6,33 @@
|
|
|
6
6
|
|
|
7
7
|
### Performance profiling for Rails, made simple.
|
|
8
8
|
|
|
9
|
-
[](https://badge.fury.io/rb/graphql-groups)
|
|
10
10
|
[](https://github.com/hschne/rails-mini-profiler/actions/workflows/main.yml)
|
|
11
|
-
[](https://codeclimate.com/github/hschne/rails-mini-profiler/maintainability)
|
|
14
|
-
[](https://codeclimate.com/github/hschne/rails-mini-profiler/test_coverage)
|
|
11
|
+
[](https://codeclimate.com/github/hschne/graphql-groups/test_coverage)
|
|
15
12
|
|
|
16
13
|
</div>
|
|
17
14
|
|
|
18
15
|
## What's this?
|
|
19
16
|
|
|
20
|
-
Rails Mini Profiler is an easy-to-use performance profiler for your Rails applications. It is heavily inspired by [Rack Mini Profiler](https://github.com/MiniProfiler/rack-mini-profiler) and other APM tools.
|
|
21
|
-
|
|
22
|
-
To see it in action view the preview below:
|
|
17
|
+
Rails Mini Profiler is an easy-to-use performance profiler for your Rails applications. It is heavily inspired by [Rack Mini Profiler](https://github.com/MiniProfiler/rack-mini-profiler) and other APM tools. It looks something like this:
|
|
23
18
|
|
|
24
|
-
<div align="center">
|
|
25
19
|
|
|
26
|
-
[](https://www.youtube.com/watch?v=fSR8fCcsO8Q)
|
|
27
20
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
**Note**: This gem is in early development and I'm looking for contributors. Try it out and leave some feedback, it really goes a long way in helping me out with development. Any [feature request](https://github.com/hschne/rails-mini-profiler/issues/new?assignees=&labels=type%3ABug&template=FEATURE_REQUEST.md&title=) or [bug report](https://github.com/hschne/rails-mini-profiler/issues/new?assignees=&labels=type%3AEnhancement&template=BUG_REPORT.md&title=) is welcome. If you like this project, leave a star to show your support! ⭐
|
|
21
|
+
**Note**: This gem is in early development and I'm looking for contributors. Try it out and leave some feedback, it really goes a long way in helping me out with development. Any [feature request](https://github.com/hschne/rails-mini-profiler/issues/new?assignees=&labels=type%3ABug&template=FEATURE_REQUEST.md&title=) or [bug report](https://github.com/hschne/rails-mini-profiler/issues/new?assignees=&labels=type%3AEnhancement&template=BUG_REPORT.md&title=) is welcome. If you like this project, leave a star to show your support! ⭐
|
|
31
22
|
|
|
32
23
|
## Getting Started
|
|
33
24
|
|
|
34
25
|
Add Rails Mini Profiler to your Gemfile:
|
|
35
26
|
|
|
36
27
|
```ruby
|
|
37
|
-
gem '
|
|
28
|
+
gem 'rails-mini-profiler'
|
|
38
29
|
```
|
|
39
30
|
|
|
40
31
|
Install the gem and run the installer:
|
|
41
32
|
|
|
42
33
|
```bash
|
|
43
34
|
bundle install
|
|
44
|
-
rails
|
|
35
|
+
rails rail_mini_profiler:install
|
|
45
36
|
```
|
|
46
37
|
|
|
47
38
|
Inspect the generated migration in `db/migrate` and run it:
|
|
@@ -51,7 +42,7 @@ rails db:migrate
|
|
|
51
42
|
```
|
|
52
43
|
|
|
53
44
|
Start your Rails application and perform some requests. You can either click the little hedgehog 🦔 on the top
|
|
54
|
-
|
|
45
|
+
right or navigate to `/rails_mini_profiler` to view collected performance metrics.
|
|
55
46
|
|
|
56
47
|
## Usage
|
|
57
48
|
|
|
@@ -64,7 +55,7 @@ route:
|
|
|
64
55
|
# routes.rb
|
|
65
56
|
Rails.application.routes.draw do
|
|
66
57
|
...
|
|
67
|
-
|
|
58
|
+
|
|
68
59
|
mount RailsMiniProfiler::Engine => '/rails_mini_profiler'
|
|
69
60
|
end
|
|
70
61
|
```
|
|
@@ -91,37 +82,35 @@ By clicking on individual traces you can find out detailed information.
|
|
|
91
82
|
|
|
92
83
|
### Flamegraphs
|
|
93
84
|
|
|
94
|
-
Rails Mini Profiler
|
|
95
|
-
|
|
85
|
+
Rails Mini Profiler per default records Flamegraphs for every profiled request for convenience. Note that Flamegraphs recording
|
|
86
|
+
incur a significant performance penalty, and can take up a lot of space.
|
|
96
87
|
|
|
97
|
-
|
|
98
|
-
gem 'stackprof'
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
For convenience, Flamegraphs are recorded for every request. This may incur a significant performance penalty. To change the default behavior see [Configuration](#Configuration).
|
|
88
|
+
To change the default behavior see [Configuration](#Configuration).
|
|
102
89
|
|
|
103
|
-
Flamegraphs are rendered using [Speedscope](https://github.com/jlfwong/speedscope).
|
|
90
|
+
Flamegraphs are rendered using [Speedscope](https://github.com/jlfwong/speedscope). If Flamegraphs are not rendering
|
|
91
|
+
you may have to amend your content security policy. See [Troubleshooting](#Troubleshooting)
|
|
104
92
|
|
|
105
93
|
## Configuration
|
|
106
94
|
|
|
107
|
-
|
|
95
|
+
You can set the following configuration options in Rails Mini Profiler:
|
|
108
96
|
|
|
109
|
-
|
|
|
97
|
+
| Option | Default | Description |
|
|
110
98
|
|--------------------------|------------------------------|-------------------------------------------------------------------------------------------------|
|
|
111
99
|
| `enabled` | `true` (dev)/ `false` (prod) | Whether or not RMP is enabled |
|
|
100
|
+
| `badge_enabled` | `true` | Should the hedgehog 🦔 badge be injected into pages? |
|
|
101
|
+
| `badge_position` | `'top-left'` | Where to display the badge. Options are `'top-left', 'top-right', 'bottom-left, 'bottom-right'` |
|
|
112
102
|
| `flamegraph_enabled` | `true` | Should flamegraphs be recorded automatically? |
|
|
113
103
|
| `flamegraph_sample_rate` | `0.5` | The flamegraph sample rate. How many snapshots per millisecond are created. |
|
|
114
104
|
| `skip_paths` | `[]` | An array of request paths that should not be profiled. Regex allowed. |
|
|
115
|
-
| `storage` | `Storage
|
|
116
|
-
| `ui` | `UserInterface.new` | UI configuration. See [UI](#UI). |
|
|
105
|
+
| `storage` | `Storage` | Storage configuration. See [Storage](#Storage) |
|
|
117
106
|
| `user_provider` | `Rack::Request.new(env).ip` | How to identify users. See [Users](#Users) |
|
|
118
107
|
|
|
119
108
|
### Request Configuration
|
|
120
109
|
|
|
121
110
|
You may override the configuration by sending request parameters. The following parameters are available:
|
|
122
111
|
|
|
123
|
-
|
|
|
124
|
-
|
|
112
|
+
| Option | Description |
|
|
113
|
+
|------------------|---------------------------------------------------------------------------------------------|
|
|
125
114
|
| `rmp_flamegraph` | Overrides `flamegraph_enabled` If set to `true` will redirect to the flamegraph immediatly. |
|
|
126
115
|
|
|
127
116
|
### Storage
|
|
@@ -129,8 +118,8 @@ You may override the configuration by sending request parameters. The following
|
|
|
129
118
|
Rails Mini Profiler stores profiling information in your database per default. You can configure various details of how
|
|
130
119
|
traces and requests are stored.
|
|
131
120
|
|
|
132
|
-
|
|
|
133
|
-
|
|
121
|
+
| Configuration | Default | Description |
|
|
122
|
+
|---------------------------|-------------------------|-----------------------------------------------------------------------------------------------------------|
|
|
134
123
|
| `database` | `nil` | Set a custom database to be used for storing profiler information. Uses `connect_to` for profiler records |
|
|
135
124
|
| `profiled_requests_table` | `rmp_profiled_requests` | The table to be used to store profiled requests. |
|
|
136
125
|
| `flamegraphs_table` | `rmp_flamegraphs` | The table to be used to store flamegraphs. |
|
|
@@ -138,7 +127,7 @@ traces and requests are stored.
|
|
|
138
127
|
|
|
139
128
|
Rails Mini Profiler does not offer an automatic way to clean up old profiling information. It is recommended you add a sweeper job to clean up old profiled requests periodically (e.g. using [clockwork](https://github.com/adamwiggins/clockwork). For example, with ActiveJob:
|
|
140
129
|
|
|
141
|
-
```
|
|
130
|
+
```
|
|
142
131
|
# Clockwork
|
|
143
132
|
every(1.month, 'purge rails mini profiler' do
|
|
144
133
|
ProfiledRequestCleanupJob.perform_later
|
|
@@ -148,22 +137,12 @@ end
|
|
|
148
137
|
class ProfiledRequestCleanupJob < ApplicationJob
|
|
149
138
|
queue_as :default
|
|
150
139
|
|
|
151
|
-
def perform
|
|
140
|
+
def perform(*guests)
|
|
152
141
|
RailsMiniProfiler::ProfiledRequest.where('created_at < ?', 1.month.ago).destroy_all
|
|
153
142
|
end
|
|
154
143
|
end
|
|
155
144
|
```
|
|
156
145
|
|
|
157
|
-
### UI
|
|
158
|
-
|
|
159
|
-
Rails Mini Profiler allows you to configure various UI features.
|
|
160
|
-
|
|
161
|
-
| Name | Default | Description |
|
|
162
|
-
|------------------|--------------|-------------------------------------------------------------------------------------------------|
|
|
163
|
-
| `badge_enabled` | `true` | Should the hedgehog 🦔 badge be injected into pages? |
|
|
164
|
-
| `badge_position` | `'top-left'` | Where to display the badge. Options are `'top-left', 'top-right', 'bottom-left, 'bottom-right'` |
|
|
165
|
-
| `page_size` | `25` | The page size for lists shown in the UI. |
|
|
166
|
-
|
|
167
146
|
### Users
|
|
168
147
|
|
|
169
148
|
Profiling information is segregated by user ID. That means users cannot see each other's profiled requests.
|
|
@@ -178,7 +157,9 @@ You may also explicitly set the user from the application itself:
|
|
|
178
157
|
|
|
179
158
|
```ruby
|
|
180
159
|
class ApplicationController < ActionController::Base
|
|
181
|
-
|
|
160
|
+
...
|
|
161
|
+
|
|
162
|
+
before_action do
|
|
182
163
|
RailsMiniProfiler::User.authorize(current_user.id)
|
|
183
164
|
end
|
|
184
165
|
end
|
|
@@ -202,71 +183,8 @@ end
|
|
|
202
183
|
|
|
203
184
|
Only requests by explicitly set users will be stored. To configure how individual users are identified see [Users](#Users)
|
|
204
185
|
|
|
205
|
-
## Why Rails Mini Profiler?
|
|
206
|
-
|
|
207
|
-
Improving the performance of any application is a 3-step process. You have to answer these questions:
|
|
208
|
-
|
|
209
|
-
1. What is slow?
|
|
210
|
-
2. Why is it slow?
|
|
211
|
-
3. Did my solution fix the slowness?
|
|
212
|
-
|
|
213
|
-
I'm a huge fan of [rack-mini-profiler](https://github.com/MiniProfiler/rack-mini-profiler), and AMP tools such as [Skylight](https://www.skylight.io/) or [Scout APM](https://scoutapm.com), and each of these tools has its place.
|
|
214
|
-
|
|
215
|
-
APM tools are excellent for profiling your app in production - aka. they show you what is slow - and offer _some_ hints as to what causes the slowdown. `rack-mini-profiler` can do some sampling in production, but excels at providing detailed insight into _why_ something is slow, using Flamegraphs and detailed query information.
|
|
216
|
-
|
|
217
|
-
Rails Mini Profiler improves upon `rack-mini-profiler` in the latter regard. It is a developer tool, rather than a monitoring tool, and sets a big focus on developer experience. Simply put, it aims to be the best tool available to help you figure out _why_ specific requests are slow.
|
|
218
|
-
|
|
219
|
-
As such, compared to `rack-mini-profiler`, it does not support non-Rails apps (e.g. Sinatra) or production sampling, but provides a much better user experience and better supports API-only applications.
|
|
220
|
-
|
|
221
186
|
## Troubleshooting
|
|
222
187
|
|
|
223
|
-
### Upgrading
|
|
224
|
-
|
|
225
|
-
Rails Mini Profiler is in early development. As such, breaking changes may still be introduced on a regular basis. While Rails Mini Profiler is in pre-release we do not offer upgrade migrations.
|
|
226
|
-
|
|
227
|
-
If an upgrade to Rails Mini Profiler breaks your application, we recommend that you clean house and start over. Re-run the initializer and overwrite existing files:
|
|
228
|
-
|
|
229
|
-
```bash
|
|
230
|
-
rails rails_mini_profiler:install
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
If only the DB schema is out of date, drop the offending tables and re-run migrations for the latest version:
|
|
234
|
-
|
|
235
|
-
```
|
|
236
|
-
rails rails_mini_profiler:install:migrations
|
|
237
|
-
rails db:migrate
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
### Support for API-Only Apps
|
|
241
|
-
|
|
242
|
-
Rails Mini Profiler supports API-only apps, but you have to make some small adjustments to use it. At the top of `application.rb` add [Sprockets](https://github.com/rails/sprockets-rails):
|
|
243
|
-
|
|
244
|
-
```
|
|
245
|
-
require "sprockets/railtie"
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
Then, modify `application.rb`:
|
|
249
|
-
|
|
250
|
-
```
|
|
251
|
-
module ApiOnly
|
|
252
|
-
class Application < Rails::Application
|
|
253
|
-
|
|
254
|
-
config.api_only = true # Either set this to false
|
|
255
|
-
config.middleware.use ActionDispatch::Flash # Or add this
|
|
256
|
-
end
|
|
257
|
-
end
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
**Note: Sprockets and flash are currently required for some of Rails Mini Profiler's UI features. These modifications may no longer be needed in the future.
|
|
261
|
-
|
|
262
|
-
### No Flamegraphs are being recored?
|
|
263
|
-
|
|
264
|
-
Make sure you have added [StackProf](https://github.com/tmm1/stackprof) to your Gemfile.
|
|
265
|
-
|
|
266
|
-
```ruby
|
|
267
|
-
gem 'stackprof'
|
|
268
|
-
```
|
|
269
|
-
|
|
270
188
|
### Flamegraphs are not rendering?
|
|
271
189
|
|
|
272
190
|
Flamegraphs are loaded into [Speedscope](https://github.com/jlfwong/speedscope) using an Iframe and URI Encoded blobs (see [source](https://github.com/hschne/rails-mini-profiler/blob/main/app/views/rails_mini_profiler/flamegraphs/show.html.erb))
|
|
@@ -284,14 +202,14 @@ end
|
|
|
284
202
|
[StackProf](https://github.com/tmm1/stackprof), which is used for recording Flamegraphs, does not work on concurrent requests.
|
|
285
203
|
Because of this, concurrent requests may skip recording a Flamegraph.
|
|
286
204
|
|
|
287
|
-
It is recommended that you resend _only_ the request you wish to
|
|
205
|
+
It is recommended that you resend _only_ the request you wish to get a Flamegraph for.
|
|
288
206
|
|
|
289
207
|
## Credit
|
|
290
208
|
|
|
291
209
|
This project was heavily inspired by projects such as [rack-mini-profiler](https://github.com/MiniProfiler/rack-mini-profiler) and
|
|
292
210
|
[rack-profiler](https://github.com/dawanda/rack-profiler). [Skylight](https://www.skylight.io/) was also a huge influence.
|
|
293
211
|
|
|
294
|
-
[Lena Schnedlitz](https://github.com/LenaSchnedlitz) designed the Logo and provided great support. Without her supreme CSS skills this project would not have been possible
|
|
212
|
+
[Lena Schnedlitz](https://github.com/LenaSchnedlitz) designed the Logo and provided great support. Without her supreme CSS skills this project would not have been possible :hands_raised:
|
|
295
213
|
|
|
296
214
|
## Contributing
|
|
297
215
|
|
data/Rakefile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
|
|
5
|
+
APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
|
|
6
|
+
load 'rails/tasks/engine.rake'
|
|
7
|
+
load 'rails/tasks/statistics.rake'
|
|
8
|
+
|
|
9
|
+
require 'bundler/gem_tasks'
|
|
10
|
+
|
|
11
|
+
require 'rspec/core/rake_task'
|
|
12
|
+
rspec = RSpec::Core::RakeTask.new(:spec)
|
|
13
|
+
rspec.verbose = false
|
|
14
|
+
|
|
15
|
+
require 'rubocop/rake_task'
|
|
16
|
+
RuboCop::RakeTask.new
|
|
17
|
+
|
|
18
|
+
task default: %i[spec rubocop]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<svg
|
|
2
|
-
<style
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1070" height="1070" viewBox="0 0 1070 1070" version="1.1">
|
|
2
|
+
<style>path{fill:none;stroke-width:64;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4}</style>
|
|
3
3
|
<defs>
|
|
4
4
|
<linearGradient id="lightShadow">
|
|
5
5
|
<stop offset="0" style="stop-color:#c22121;stop-opacity:1"/>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
3
|
+
<title>Iconly/Bulk/Search</title>
|
|
4
|
+
<g id="Iconly/Bulk/Search" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
5
|
+
<g id="Search" transform="translate(2.000000, 2.000000)" fill="#000000" fill-rule="nonzero">
|
|
6
|
+
<ellipse id="Ellipse_746" cx="8.59921927" cy="8.65324385" rx="8.59921927" ry="8.65324385"></ellipse>
|
|
7
|
+
<path d="M18.674623,19.9552573 C18.3405833,19.9444414 18.0229443,19.8069986 17.7853553,19.5704698 L15.7489321,17.1901566 C15.3123366,16.7908936 15.2766365,16.1123232 15.668898,15.6689038 L15.668898,15.6689038 C15.8525005,15.4831065 16.1021409,15.3786387 16.3625268,15.3786387 C16.6229128,15.3786387 16.8725531,15.4831065 17.0561557,15.6689038 L19.6172468,17.7181208 C19.9861582,18.0957076 20.0999999,18.656254 19.9078887,19.1492153 C19.7157774,19.6421767 19.2536179,19.9754211 18.7279791,20 L18.674623,19.9552573 Z" id="Path_34202" opacity="0.400000006"></path>
|
|
8
|
+
</g>
|
|
9
|
+
</g>
|
|
10
|
+
</svg>
|
|
File without changes
|
|
File without changes
|
|
@@ -12,4 +12,79 @@
|
|
|
12
12
|
//
|
|
13
13
|
//= require rails-ujs
|
|
14
14
|
//= require_tree .
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
function setupRequestSearch() {
|
|
17
|
+
const profiledRequestNameSearch = document.getElementById('profiled-request-search')
|
|
18
|
+
if (profiledRequestNameSearch) {
|
|
19
|
+
profiledRequestNameSearch.addEventListener('keyup', function (event) {
|
|
20
|
+
if (event.key === 'Enter') {
|
|
21
|
+
event.preventDefault()
|
|
22
|
+
document.getElementById('profiled-request-search-form').submit()
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function setupTraceSearch() {
|
|
29
|
+
const traceNameSearch = document.getElementById('trace-search')
|
|
30
|
+
if (traceNameSearch) {
|
|
31
|
+
traceNameSearch.addEventListener('keyup', function (event) {
|
|
32
|
+
if (event.key === 'Enter') {
|
|
33
|
+
event.preventDefault()
|
|
34
|
+
document.getElementById('trace-form').submit()
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function setupRequestTable() {
|
|
41
|
+
const profiledRequestTable = document.getElementById('profiled-requests-table');
|
|
42
|
+
if (profiledRequestTable) {
|
|
43
|
+
const rows = profiledRequestTable.getElementsByTagName('tr')
|
|
44
|
+
for (let i = 0; i < rows.length; i++) {
|
|
45
|
+
const currentRow = profiledRequestTable.rows[i]
|
|
46
|
+
const link = currentRow.dataset.link
|
|
47
|
+
const createClickHandler = function (currentRow) {
|
|
48
|
+
return function () {
|
|
49
|
+
window.location.href = link
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
currentRow.onclick = createClickHandler(currentRow)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function setupTraceBars () {
|
|
58
|
+
const traceBars = document.querySelectorAll('.trace-bar')
|
|
59
|
+
traceBars.forEach((bar) => {
|
|
60
|
+
const popover = bar.children[0]
|
|
61
|
+
tippy(bar, {
|
|
62
|
+
trigger: 'click',
|
|
63
|
+
content: popover,
|
|
64
|
+
theme: 'rmp',
|
|
65
|
+
maxWidth: '700px',
|
|
66
|
+
placement: 'bottom',
|
|
67
|
+
interactive: true,
|
|
68
|
+
onShow (instance) {
|
|
69
|
+
instance.popper.querySelector('.popover-close').addEventListener('click', () => {
|
|
70
|
+
instance.hide()
|
|
71
|
+
})
|
|
72
|
+
},
|
|
73
|
+
onHide (instance) {
|
|
74
|
+
instance.popper.querySelector('.popover-close').removeEventListener('click', () => {
|
|
75
|
+
instance.hide()
|
|
76
|
+
})
|
|
77
|
+
},
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
// Trace Bar Popovers
|
|
84
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
85
|
+
setupRequestTable();
|
|
86
|
+
setupRequestSearch();
|
|
87
|
+
setupTraceBars();
|
|
88
|
+
setupTraceSearch();
|
|
89
|
+
}, false)
|
|
90
|
+
|
|
@@ -12,5 +12,153 @@
|
|
|
12
12
|
*
|
|
13
13
|
*= require_tree .
|
|
14
14
|
*= require_self
|
|
15
|
-
*= require rails-mini-profiler
|
|
16
15
|
*/
|
|
16
|
+
|
|
17
|
+
html {
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: 100%;
|
|
20
|
+
margin: 0;
|
|
21
|
+
padding: 0;
|
|
22
|
+
|
|
23
|
+
--grey-50: #F9FAFB;
|
|
24
|
+
--grey-100: #F3F4F6;
|
|
25
|
+
--grey-200: #E5E7EB;
|
|
26
|
+
--grey-400: #9CA3AF;
|
|
27
|
+
--grey-500: #6B7280;
|
|
28
|
+
--grey-700: #374151;
|
|
29
|
+
--grey-900: #111827;
|
|
30
|
+
|
|
31
|
+
--red-400: #F87171;
|
|
32
|
+
--red-500: #EF4444;
|
|
33
|
+
--red-600: #DC2626;
|
|
34
|
+
|
|
35
|
+
--yellow-400: #FBBF24;
|
|
36
|
+
--yellow-500: #F59E0B;
|
|
37
|
+
|
|
38
|
+
--green-300: #6EE7B7;
|
|
39
|
+
--green-400: #34D399;
|
|
40
|
+
--green-500: #10B981;
|
|
41
|
+
|
|
42
|
+
--blue-400: #60A5FA;
|
|
43
|
+
--blue-500: #3B82F6;
|
|
44
|
+
|
|
45
|
+
--main-width: 1056px;
|
|
46
|
+
|
|
47
|
+
--primary: var(--red-600);
|
|
48
|
+
|
|
49
|
+
--border-color: var(--grey-200);
|
|
50
|
+
--text-color: var(--grey-900);
|
|
51
|
+
|
|
52
|
+
font-family: 'Open Sans', sans-serif;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
body {
|
|
56
|
+
width: 100%;
|
|
57
|
+
height: 100%;
|
|
58
|
+
margin: 0;
|
|
59
|
+
padding: 0;
|
|
60
|
+
|
|
61
|
+
color: var(--text-color)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
h1 {
|
|
65
|
+
padding: 2rem 0 1rem;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
button {
|
|
69
|
+
border: none;
|
|
70
|
+
border-radius: .25rem;
|
|
71
|
+
padding: 0.5em .5em;
|
|
72
|
+
text-align: center;
|
|
73
|
+
text-decoration: none;
|
|
74
|
+
display: inline-block;
|
|
75
|
+
font-size: 1rem;
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
button:hover {
|
|
80
|
+
box-shadow: 0 .25rem .25rem 0 var(--grey-50);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* --------------------------------------- */
|
|
84
|
+
|
|
85
|
+
.text-left {
|
|
86
|
+
text-align: left;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.text-right {
|
|
90
|
+
text-align: right;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* --------------------------------------- */
|
|
94
|
+
|
|
95
|
+
.pill {
|
|
96
|
+
margin: .2rem 0;
|
|
97
|
+
padding: .1rem .4rem;
|
|
98
|
+
border-radius: 5px;
|
|
99
|
+
|
|
100
|
+
font-size: .9rem;
|
|
101
|
+
font-weight: 600;
|
|
102
|
+
letter-spacing: .1rem;
|
|
103
|
+
|
|
104
|
+
background: var(--grey-200);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* --------------------------------------- */
|
|
108
|
+
|
|
109
|
+
.popover {
|
|
110
|
+
display: flex;
|
|
111
|
+
flex-direction: column;
|
|
112
|
+
width: 600px;
|
|
113
|
+
padding: 1em;
|
|
114
|
+
color: black;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.popover-header {
|
|
118
|
+
display: flex;
|
|
119
|
+
padding-bottom: 1em;
|
|
120
|
+
flex-direction: row;
|
|
121
|
+
justify-content: space-between;
|
|
122
|
+
align-items: center;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.popover-description {
|
|
126
|
+
margin: 0;
|
|
127
|
+
padding: 0;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.popover-close {
|
|
131
|
+
background: transparent;
|
|
132
|
+
padding: 0;
|
|
133
|
+
font-weight: 700;
|
|
134
|
+
font-size: 20px;
|
|
135
|
+
color: var(--grey-400);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.popover-body {
|
|
139
|
+
padding: 1em 0;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.popover-footer {
|
|
143
|
+
border-top: 1px solid var(--grey-50);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.tippy-box[data-theme~='rmp'] {
|
|
147
|
+
background: white;
|
|
148
|
+
box-shadow: 8px 0 30px 4px rgba(0, 0, 0, .2), 8px 4px 10px 0 rgba(0, 0, 0, .05);
|
|
149
|
+
border-radius: 3px;
|
|
150
|
+
|
|
151
|
+
transition: all cubic-bezier(.19,1,.22,1) .2s;
|
|
152
|
+
}
|
|
153
|
+
.tippy-box[data-theme~='rmp'][data-placement^='top'] > .tippy-arrow::before {
|
|
154
|
+
border-top-color: white;
|
|
155
|
+
}
|
|
156
|
+
.tippy-box[data-theme~='rmp'][data-placement^='bottom'] > .tippy-arrow::before {
|
|
157
|
+
border-bottom-color: white;
|
|
158
|
+
}
|
|
159
|
+
.tippy-box[data-theme~='rmp'][data-placement^='left'] > .tippy-arrow::before {
|
|
160
|
+
border-left-color: white;
|
|
161
|
+
}
|
|
162
|
+
.tippy-box[data-theme~='rmp'][data-placement^='right'] > .tippy-arrow::before {
|
|
163
|
+
border-right-color: white;
|
|
164
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Place all the styles related to the matching controller here.
|
|
3
|
+
They will automatically be included in application.css.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#wrapper {
|
|
7
|
+
height: 100vh;
|
|
8
|
+
width: 100%;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
#speedscope-iframe {
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 100%;
|
|
14
|
+
border: none; }
|
data/app/{javascript/stylesheets/flashes.scss → assets/stylesheets/rails_mini_profiler/flashes.css}
RENAMED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
.flash {
|
|
2
|
-
padding: 1rem 1rem;
|
|
3
2
|
margin-top: 1rem;
|
|
3
|
+
padding: 1rem 1rem;
|
|
4
|
+
|
|
4
5
|
border-radius: 5px;
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
.flash-error {
|
|
8
|
-
background: var(--red-500);
|
|
9
9
|
color: white;
|
|
10
|
+
background: var(--red-500);
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
.flash-notice {
|
|
13
|
-
background: var(--green-400);
|
|
14
14
|
color: white;
|
|
15
|
+
background: var(--green-400);
|
|
16
|
+
|
|
15
17
|
}
|
data/app/{javascript/stylesheets/navbar.scss → assets/stylesheets/rails_mini_profiler/navbar.css}
RENAMED
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
.header {
|
|
2
|
+
margin: 0;
|
|
3
|
+
padding: 1.5rem 0;
|
|
4
|
+
|
|
2
5
|
display: flex;
|
|
3
6
|
justify-content: center;
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
|
|
8
|
+
box-shadow: 0 0 20px 0 rgba(0,0,0,.2);
|
|
9
|
+
|
|
6
10
|
background: var(--primary);
|
|
7
|
-
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2);
|
|
8
11
|
}
|
|
9
12
|
|
|
10
13
|
.header a {
|
|
11
|
-
color:
|
|
14
|
+
color:white;
|
|
12
15
|
text-decoration: none;
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
.nav {
|
|
16
|
-
display: flex;
|
|
17
19
|
width: var(--main-width);
|
|
20
|
+
|
|
21
|
+
display: flex;
|
|
18
22
|
justify-content: space-between;
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
.home {
|
|
22
26
|
display: flex;
|
|
23
27
|
align-items: center;
|
|
28
|
+
|
|
24
29
|
text-decoration: none;
|
|
25
30
|
}
|
|
26
31
|
|
|
@@ -35,10 +40,11 @@
|
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
.header-links {
|
|
43
|
+
margin: 0;
|
|
44
|
+
padding: 0;
|
|
45
|
+
list-style: none;
|
|
38
46
|
display: flex;
|
|
39
47
|
align-items: center;
|
|
40
|
-
|
|
41
|
-
margin: 0;
|
|
48
|
+
|
|
42
49
|
font-weight: 700;
|
|
43
|
-
list-style: none;
|
|
44
50
|
}
|