rails_mini_profiler 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b1f043e04e0f4aaf67b7cfe22be413aa689e51553c3e30e535b2a828d5abde2
4
- data.tar.gz: '028d6a1d92f6d66552ccf5f7ea9d1c622d15551ba16977c53b773041fd48464c'
3
+ metadata.gz: 68745f57dfbd4c05a60722a699c377ec8b5eb6f101edc3259bec8134f3b8078e
4
+ data.tar.gz: c28c669797fb80f92590a9b7574878c59bc0050c415b939d14936c2caf7127d1
5
5
  SHA512:
6
- metadata.gz: 4722b94b458742b5f0c3f3ebe12c119054f053f9a4c783748e5e72686f5676de3fdc7ea5ff9c7aa1bc3872e4ed1d139934aeeb7f653ab40a4818d11b268b85ef
7
- data.tar.gz: '0958d98854d3df4c1129a2aef7a85dbf0053770f6c761b7901bf3e121acbb2d1116308d419364ce5528b1b8458d68368bb6f32938966b5a35215c45fe8cd2872'
6
+ metadata.gz: 8c2a6559821ce43c54dd30f1f8c396734b2f8d2559b81802553a31197f7a1cdafbd7ee25756f59ea51e3b6aa4685a6184a9b8972bdc3b761e7ac4b6261724ee2
7
+ data.tar.gz: 34af332d02f3e9a7de68e74a3f900b8c58c57bed9f7fcb37b4c7125e9086c57d446885d8778755d92bddcbb10cd8b5e3393c066877ca9844cffec9e712a82506
data/README.md CHANGED
@@ -6,33 +6,42 @@
6
6
 
7
7
  ### Performance profiling for Rails, made simple.
8
8
 
9
- [![Gem Version](https://badge.fury.io/rb/graphql-groups.svg)](https://badge.fury.io/rb/graphql-groups)
9
+ [![Gem Version](https://badge.fury.io/rb/rails_mini_profiler.svg)](https://badge.fury.io/rb/rails_mini_profiler)
10
10
  [![Main](https://github.com/hschne/rails-mini-profiler/actions/workflows/main.yml/badge.svg)](https://github.com/hschne/rails-mini-profiler/actions/workflows/main.yml)
11
- [![Test Coverage](https://api.codeclimate.com/v1/badges/692d4125ac8548fb145e/test_coverage)](https://codeclimate.com/github/hschne/graphql-groups/test_coverage)
11
+ [![Main](https://img.shields.io/github/license/hschne/rails-mini-profiler)](https://img.shields.io/github/license/hschne/rails-mini-profiler)
12
+
13
+ [![Maintainability](https://api.codeclimate.com/v1/badges/1fcc2f4d01ab5bf7a260/maintainability)](https://codeclimate.com/github/hschne/rails-mini-profiler/maintainability)
14
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/1fcc2f4d01ab5bf7a260/test_coverage)](https://codeclimate.com/github/hschne/rails-mini-profiler/test_coverage)
12
15
 
13
16
  </div>
14
17
 
15
18
  ## What's this?
16
19
 
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:
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. To find out how it stacks up against those check out [Why Rails Mini Profiler](#why-rails-mini-profiler)?
21
+
22
+ To see it in action view the preview below:
23
+
24
+ <div align="center">
18
25
 
26
+ [![Rails Mini Profiler Preview](http://img.youtube.com/vi/fSR8fCcsO8Q/0.jpg)](https://www.youtube.com/watch?v=fSR8fCcsO8Q)
19
27
 
28
+ </div>
20
29
 
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! ⭐
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! ⭐
22
31
 
23
32
  ## Getting Started
24
33
 
25
34
  Add Rails Mini Profiler to your Gemfile:
26
35
 
27
36
  ```ruby
28
- gem 'rails-mini-profiler'
37
+ gem 'rails_mini_profiler'
29
38
  ```
30
39
 
31
40
  Install the gem and run the installer:
32
41
 
33
42
  ```bash
34
43
  bundle install
35
- rails rail_mini_profiler:install
44
+ rails rails_mini_profiler:install
36
45
  ```
37
46
 
38
47
  Inspect the generated migration in `db/migrate` and run it:
@@ -42,7 +51,7 @@ rails db:migrate
42
51
  ```
43
52
 
44
53
  Start your Rails application and perform some requests. You can either click the little hedgehog 🦔 on the top
45
- right or navigate to `/rails_mini_profiler` to view collected performance metrics.
54
+ left or navigate to `/rails_mini_profiler` to view collected performance metrics.
46
55
 
47
56
  ## Usage
48
57
 
@@ -55,7 +64,7 @@ route:
55
64
  # routes.rb
56
65
  Rails.application.routes.draw do
57
66
  ...
58
-
67
+
59
68
  mount RailsMiniProfiler::Engine => '/rails_mini_profiler'
60
69
  end
61
70
  ```
@@ -95,7 +104,7 @@ you may have to amend your content security policy. See [Troubleshooting](#Troub
95
104
  You can set the following configuration options in Rails Mini Profiler:
96
105
 
97
106
  | Option | Default | Description |
98
- |--------------------------|------------------------------|-------------------------------------------------------------------------------------------------|
107
+ | ------------------------ | ---------------------------- | ----------------------------------------------------------------------------------------------- |
99
108
  | `enabled` | `true` (dev)/ `false` (prod) | Whether or not RMP is enabled |
100
109
  | `badge_enabled` | `true` | Should the hedgehog 🦔 badge be injected into pages? |
101
110
  | `badge_position` | `'top-left'` | Where to display the badge. Options are `'top-left', 'top-right', 'bottom-left, 'bottom-right'` |
@@ -110,7 +119,7 @@ You can set the following configuration options in Rails Mini Profiler:
110
119
  You may override the configuration by sending request parameters. The following parameters are available:
111
120
 
112
121
  | Option | Description |
113
- |------------------|---------------------------------------------------------------------------------------------|
122
+ | ---------------- | ------------------------------------------------------------------------------------------- |
114
123
  | `rmp_flamegraph` | Overrides `flamegraph_enabled` If set to `true` will redirect to the flamegraph immediatly. |
115
124
 
116
125
  ### Storage
@@ -119,7 +128,7 @@ Rails Mini Profiler stores profiling information in your database per default. Y
119
128
  traces and requests are stored.
120
129
 
121
130
  | Configuration | Default | Description |
122
- |---------------------------|-------------------------|-----------------------------------------------------------------------------------------------------------|
131
+ | ------------------------- | ----------------------- | --------------------------------------------------------------------------------------------------------- |
123
132
  | `database` | `nil` | Set a custom database to be used for storing profiler information. Uses `connect_to` for profiler records |
124
133
  | `profiled_requests_table` | `rmp_profiled_requests` | The table to be used to store profiled requests. |
125
134
  | `flamegraphs_table` | `rmp_flamegraphs` | The table to be used to store flamegraphs. |
@@ -137,7 +146,7 @@ end
137
146
  class ProfiledRequestCleanupJob < ApplicationJob
138
147
  queue_as :default
139
148
 
140
- def perform(*guests)
149
+ def perform
141
150
  RailsMiniProfiler::ProfiledRequest.where('created_at < ?', 1.month.ago).destroy_all
142
151
  end
143
152
  end
@@ -158,8 +167,8 @@ You may also explicitly set the user from the application itself:
158
167
  ```ruby
159
168
  class ApplicationController < ActionController::Base
160
169
  ...
161
-
162
- before_action do
170
+
171
+ before_action do
163
172
  RailsMiniProfiler::User.authorize(current_user.id)
164
173
  end
165
174
  end
@@ -183,8 +192,35 @@ end
183
192
 
184
193
  Only requests by explicitly set users will be stored. To configure how individual users are identified see [Users](#Users)
185
194
 
195
+ ## Why Rails Mini Profiler?
196
+
197
+ Improving the performance of any application is a 3-step process. You have to answer these questions:
198
+
199
+ 1. What is slow?
200
+ 2. Why is it slow?
201
+ 3. Did my solution fix the slowness?
202
+
203
+ 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.
204
+
205
+ 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.
206
+
207
+ 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.
208
+
209
+ 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.
210
+
186
211
  ## Troubleshooting
187
212
 
213
+ ### Upgrading
214
+
215
+ 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.
216
+
217
+ If an upgrade to Rails Mini Profiler breaks your application, we recommend that you drop the offending tables and re-run migrations for the latest version:
218
+
219
+ ```
220
+ rails rails_mini_profiler:install:migrations
221
+ rails db:migrate
222
+ ```
223
+
188
224
  ### Flamegraphs are not rendering?
189
225
 
190
226
  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))
@@ -202,14 +238,14 @@ end
202
238
  [StackProf](https://github.com/tmm1/stackprof), which is used for recording Flamegraphs, does not work on concurrent requests.
203
239
  Because of this, concurrent requests may skip recording a Flamegraph.
204
240
 
205
- It is recommended that you resend _only_ the request you wish to get a Flamegraph for.
241
+ It is recommended that you resend _only_ the request you wish to build a Flamegraph for.
206
242
 
207
243
  ## Credit
208
244
 
209
245
  This project was heavily inspired by projects such as [rack-mini-profiler](https://github.com/MiniProfiler/rack-mini-profiler) and
210
246
  [rack-profiler](https://github.com/dawanda/rack-profiler). [Skylight](https://www.skylight.io/) was also a huge influence.
211
247
 
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:
248
+ [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 🙌
213
249
 
214
250
  ## Contributing
215
251
 
@@ -7,15 +7,19 @@
7
7
  # id :integer not null, primary key
8
8
  # rmp_profiled_request_id :bigint not null
9
9
  # name :string
10
- # start :integer
11
- # finish :integer
10
+ # start :bigint
11
+ # finish :bigint
12
12
  # duration :integer
13
- # allocations :integer
13
+ # allocations :bigint
14
14
  # payload :json
15
15
  # backtrace :json
16
16
  # created_at :datetime not null
17
17
  # updated_at :datetime not null
18
18
  #
19
+ # Indexes
20
+ #
21
+ # index_rmp_traces_on_rmp_profiled_request_id (rmp_profiled_request_id)
22
+ #
19
23
  module RailsMiniProfiler
20
24
  class ControllerTrace < Trace
21
25
  store :payload, accessors: %i[view_runtime db_runtime]
@@ -10,6 +10,10 @@
10
10
  # created_at :datetime not null
11
11
  # updated_at :datetime not null
12
12
  #
13
+ # Indexes
14
+ #
15
+ # index_rmp_flamegraphs_on_rmp_profiled_request_id (rmp_profiled_request_id)
16
+ #
13
17
  module RailsMiniProfiler
14
18
  class Flamegraph < RailsMiniProfiler::ApplicationRecord
15
19
  self.table_name = RailsMiniProfiler.storage_configuration.flamegraphs_table
@@ -7,15 +7,19 @@
7
7
  # id :integer not null, primary key
8
8
  # rmp_profiled_request_id :bigint not null
9
9
  # name :string
10
- # start :integer
11
- # finish :integer
10
+ # start :bigint
11
+ # finish :bigint
12
12
  # duration :integer
13
- # allocations :integer
13
+ # allocations :bigint
14
14
  # payload :json
15
15
  # backtrace :json
16
16
  # created_at :datetime not null
17
17
  # updated_at :datetime not null
18
18
  #
19
+ # Indexes
20
+ #
21
+ # index_rmp_traces_on_rmp_profiled_request_id (rmp_profiled_request_id)
22
+ #
19
23
  module RailsMiniProfiler
20
24
  class InstantiationTrace < Trace
21
25
  store :payload, accessors: %i[record_count class_name]
@@ -4,21 +4,27 @@
4
4
  #
5
5
  # Table name: rmp_profiled_requests
6
6
  #
7
- # id :integer not null, primary key
8
- # user_id :string
9
- # start :integer
10
- # finish :integer
11
- # duration :integer
12
- # allocations :integer
13
- # request_path :string
14
- # request_method :string
15
- # request_headers :json
16
- # request_body :json
17
- # response_status :integer
18
- # response_body :json
19
- # response_headers :json
20
- # created_at :datetime not null
21
- # updated_at :datetime not null
7
+ # id :integer not null, primary key
8
+ # user_id :string
9
+ # start :bigint
10
+ # finish :bigint
11
+ # duration :integer
12
+ # allocations :bigint
13
+ # request_path :string
14
+ # request_query_string :string
15
+ # request_method :string
16
+ # request_headers :json
17
+ # request_body :text
18
+ # response_status :integer
19
+ # response_body :text
20
+ # response_headers :json
21
+ # response_media_type :string
22
+ # created_at :datetime not null
23
+ # updated_at :datetime not null
24
+ #
25
+ # Indexes
26
+ #
27
+ # index_rmp_profiled_requests_on_created_at (created_at)
22
28
  #
23
29
  module RailsMiniProfiler
24
30
  class ProfiledRequest < RailsMiniProfiler::ApplicationRecord
@@ -7,15 +7,19 @@
7
7
  # id :integer not null, primary key
8
8
  # rmp_profiled_request_id :bigint not null
9
9
  # name :string
10
- # start :integer
11
- # finish :integer
10
+ # start :bigint
11
+ # finish :bigint
12
12
  # duration :integer
13
- # allocations :integer
13
+ # allocations :bigint
14
14
  # payload :json
15
15
  # backtrace :json
16
16
  # created_at :datetime not null
17
17
  # updated_at :datetime not null
18
18
  #
19
+ # Indexes
20
+ #
21
+ # index_rmp_traces_on_rmp_profiled_request_id (rmp_profiled_request_id)
22
+ #
19
23
  module RailsMiniProfiler
20
24
  class RenderPartialTrace < Trace
21
25
  store :payload, accessors: %i[identifier]
@@ -7,15 +7,19 @@
7
7
  # id :integer not null, primary key
8
8
  # rmp_profiled_request_id :bigint not null
9
9
  # name :string
10
- # start :integer
11
- # finish :integer
10
+ # start :bigint
11
+ # finish :bigint
12
12
  # duration :integer
13
- # allocations :integer
13
+ # allocations :bigint
14
14
  # payload :json
15
15
  # backtrace :json
16
16
  # created_at :datetime not null
17
17
  # updated_at :datetime not null
18
18
  #
19
+ # Indexes
20
+ #
21
+ # index_rmp_traces_on_rmp_profiled_request_id (rmp_profiled_request_id)
22
+ #
19
23
  module RailsMiniProfiler
20
24
  class RenderTemplateTrace < Trace
21
25
  store :payload, accessors: %i[identifier]
@@ -7,15 +7,19 @@
7
7
  # id :integer not null, primary key
8
8
  # rmp_profiled_request_id :bigint not null
9
9
  # name :string
10
- # start :integer
11
- # finish :integer
10
+ # start :bigint
11
+ # finish :bigint
12
12
  # duration :integer
13
- # allocations :integer
13
+ # allocations :bigint
14
14
  # payload :json
15
15
  # backtrace :json
16
16
  # created_at :datetime not null
17
17
  # updated_at :datetime not null
18
18
  #
19
+ # Indexes
20
+ #
21
+ # index_rmp_traces_on_rmp_profiled_request_id (rmp_profiled_request_id)
22
+ #
19
23
  module RailsMiniProfiler
20
24
  class RmpTrace < Trace
21
25
  class << self
@@ -7,15 +7,19 @@
7
7
  # id :integer not null, primary key
8
8
  # rmp_profiled_request_id :bigint not null
9
9
  # name :string
10
- # start :integer
11
- # finish :integer
10
+ # start :bigint
11
+ # finish :bigint
12
12
  # duration :integer
13
- # allocations :integer
13
+ # allocations :bigint
14
14
  # payload :json
15
15
  # backtrace :json
16
16
  # created_at :datetime not null
17
17
  # updated_at :datetime not null
18
18
  #
19
+ # Indexes
20
+ #
21
+ # index_rmp_traces_on_rmp_profiled_request_id (rmp_profiled_request_id)
22
+ #
19
23
  module RailsMiniProfiler
20
24
  class SequelTrace < Trace
21
25
  store :payload, accessors: %i[name sql binds]
@@ -7,15 +7,19 @@
7
7
  # id :integer not null, primary key
8
8
  # rmp_profiled_request_id :bigint not null
9
9
  # name :string
10
- # start :integer
11
- # finish :integer
10
+ # start :bigint
11
+ # finish :bigint
12
12
  # duration :integer
13
- # allocations :integer
13
+ # allocations :bigint
14
14
  # payload :json
15
15
  # backtrace :json
16
16
  # created_at :datetime not null
17
17
  # updated_at :datetime not null
18
18
  #
19
+ # Indexes
20
+ #
21
+ # index_rmp_traces_on_rmp_profiled_request_id (rmp_profiled_request_id)
22
+ #
19
23
  module RailsMiniProfiler
20
24
  class Trace < RailsMiniProfiler::ApplicationRecord
21
25
  self.table_name = RailsMiniProfiler.storage_configuration.traces_table
@@ -4,10 +4,10 @@ class CreateRmp < ActiveRecord::Migration[6.0]
4
4
  def change
5
5
  create_table :rmp_profiled_requests do |t|
6
6
  t.string :user_id
7
- t.integer :start
8
- t.integer :finish
7
+ t.bigint :start
8
+ t.bigint :finish
9
9
  t.integer :duration
10
- t.integer :allocations
10
+ t.bigint :allocations
11
11
  t.string :request_path
12
12
  t.string :request_query_string
13
13
  t.string :request_method
@@ -19,15 +19,17 @@ class CreateRmp < ActiveRecord::Migration[6.0]
19
19
  t.string :response_media_type
20
20
 
21
21
  t.timestamps
22
+
23
+ t.index :created_at
22
24
  end
23
25
 
24
26
  create_table :rmp_traces do |t|
25
27
  t.belongs_to :rmp_profiled_request, null: false, foreign_key: true
26
28
  t.string :name
27
- t.integer :start
28
- t.integer :finish
29
+ t.bigint :start
30
+ t.bigint :finish
29
31
  t.integer :duration
30
- t.integer :allocations
32
+ t.bigint :allocations
31
33
  t.json :payload
32
34
  t.json :backtrace
33
35
 
@@ -6,7 +6,7 @@ RailsMiniProfiler.configure do |config|
6
6
  # config.flamegraph_enabled = false
7
7
 
8
8
  # Use RailsMiniProfiler::Storage::ActiveRecord to store profiles in your Database
9
- config.storage = RailsMiniProfiler::Storage::Memory
9
+ config.storage = RailsMiniProfiler::Storage
10
10
 
11
11
  # Uncomment to customize how users are detected
12
12
  # config.user_provider = proc { |env| Rack::Request.new(env).ip }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsMiniProfiler
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_mini_profiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - hschne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-27 00:00:00.000000000 Z
11
+ date: 2021-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inline_svg