rails_mini_profiler 0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,180 @@
|
|
1
|
+
/*
|
2
|
+
Place all the styles related to the matching controller here.
|
3
|
+
They will automatically be included in application.css.
|
4
|
+
*/
|
5
|
+
|
6
|
+
|
7
|
+
main {
|
8
|
+
width: 100%;
|
9
|
+
|
10
|
+
display: flex;
|
11
|
+
justify-content: center;
|
12
|
+
}
|
13
|
+
|
14
|
+
.main-section {
|
15
|
+
width: var(--main-width);
|
16
|
+
}
|
17
|
+
|
18
|
+
.placeholder {
|
19
|
+
display: flex;
|
20
|
+
flex-direction: column;
|
21
|
+
justify-content: center;
|
22
|
+
align-items: center;
|
23
|
+
width: 100%;
|
24
|
+
height: 450px;
|
25
|
+
}
|
26
|
+
|
27
|
+
.placeholder-image {
|
28
|
+
height: 30%;
|
29
|
+
width: 30%;
|
30
|
+
-webkit-filter: grayscale(1) brightness(2.5);
|
31
|
+
}
|
32
|
+
|
33
|
+
.placeholder-text {
|
34
|
+
text-align: center;
|
35
|
+
color: var(--grey-400);
|
36
|
+
}
|
37
|
+
|
38
|
+
.profiled-requests-actions {
|
39
|
+
display: flex;
|
40
|
+
padding: 1rem 0;
|
41
|
+
justify-content: space-between;
|
42
|
+
align-items: center;
|
43
|
+
}
|
44
|
+
|
45
|
+
.search-field {
|
46
|
+
padding: 0.5rem .5rem;
|
47
|
+
border-radius: .25em;
|
48
|
+
|
49
|
+
border: 1px solid var(--grey-400);
|
50
|
+
color: var(--grey-700) ;
|
51
|
+
}
|
52
|
+
|
53
|
+
.clear-action button {
|
54
|
+
background: var(--red-500);
|
55
|
+
color: white;
|
56
|
+
}
|
57
|
+
|
58
|
+
.table {
|
59
|
+
width: 100%;
|
60
|
+
/* Hack to get table row borders, see https://stackoverflow.com/a/2586780/2553104 */
|
61
|
+
border-collapse: collapse;
|
62
|
+
border-radius: 5px;
|
63
|
+
border: hidden 1px var(--border-color);
|
64
|
+
box-shadow: 0 0 0 1px var(--border-color);
|
65
|
+
}
|
66
|
+
|
67
|
+
.table thead tr {
|
68
|
+
color: var(--grey-400);
|
69
|
+
}
|
70
|
+
|
71
|
+
.table thead th {
|
72
|
+
font-weight: 400;
|
73
|
+
}
|
74
|
+
|
75
|
+
.table tr {
|
76
|
+
border: solid 1px var(--border-color);
|
77
|
+
color: var(--grey-700);
|
78
|
+
cursor: pointer;
|
79
|
+
}
|
80
|
+
|
81
|
+
.table tr:nth-child(even) {
|
82
|
+
background: var(--grey-50);
|
83
|
+
}
|
84
|
+
|
85
|
+
.table tbody tr:hover {
|
86
|
+
background: var(--grey-100);
|
87
|
+
}
|
88
|
+
|
89
|
+
.table th,
|
90
|
+
.table td {
|
91
|
+
padding: 0.5rem 1rem;
|
92
|
+
}
|
93
|
+
|
94
|
+
.request-path {
|
95
|
+
max-width: 300px;
|
96
|
+
|
97
|
+
white-space: nowrap;
|
98
|
+
overflow: hidden;
|
99
|
+
text-overflow: ellipsis;
|
100
|
+
}
|
101
|
+
|
102
|
+
.request-buttons {
|
103
|
+
z-index: 1;
|
104
|
+
text-align: right;
|
105
|
+
}
|
106
|
+
|
107
|
+
.request-buttons a {
|
108
|
+
text-decoration: none;
|
109
|
+
padding: 0 .25rem;
|
110
|
+
color: var(--grey-700);
|
111
|
+
}
|
112
|
+
|
113
|
+
.request-buttons a:active,
|
114
|
+
.request-buttons a:focus-visible,
|
115
|
+
.request-buttons a:hover {
|
116
|
+
color: var(--blue-500);
|
117
|
+
}
|
118
|
+
|
119
|
+
.request-buttons a.link-disabled {
|
120
|
+
cursor: default;
|
121
|
+
pointer-events: none;
|
122
|
+
text-decoration: none;
|
123
|
+
color: var(--grey-200);
|
124
|
+
}
|
125
|
+
|
126
|
+
.request-details-data {
|
127
|
+
display: flex;
|
128
|
+
|
129
|
+
margin: 0;
|
130
|
+
padding: 0;
|
131
|
+
}
|
132
|
+
|
133
|
+
.data-item {
|
134
|
+
display: flex;
|
135
|
+
flex-direction: column;
|
136
|
+
align-items: start;
|
137
|
+
list-style: none;
|
138
|
+
|
139
|
+
margin-right: 3rem;
|
140
|
+
padding: 0;
|
141
|
+
}
|
142
|
+
|
143
|
+
.data-item small {
|
144
|
+
color: var(--grey-400);
|
145
|
+
}
|
146
|
+
|
147
|
+
.data-item span {
|
148
|
+
margin: .25rem 0;
|
149
|
+
}
|
150
|
+
|
151
|
+
[class*='request-status-2'],
|
152
|
+
[class*='request-method-get'] {
|
153
|
+
color: white;
|
154
|
+
background: var(--green-400) !important;
|
155
|
+
}
|
156
|
+
|
157
|
+
[class*='request-status-4'],
|
158
|
+
[class*='request-method-put'],
|
159
|
+
[class*='request-method-patch'] {
|
160
|
+
color: white;
|
161
|
+
background: var(--yellow-400) !important;
|
162
|
+
}
|
163
|
+
|
164
|
+
[class*='request-status-5'],
|
165
|
+
[class*='request-method-delete'] {
|
166
|
+
color: white;
|
167
|
+
background: var(--red-500) !important;
|
168
|
+
}
|
169
|
+
|
170
|
+
.request-details-actions {
|
171
|
+
margin: 0;
|
172
|
+
padding: 2em 0;
|
173
|
+
display: flex;
|
174
|
+
align-items: center;
|
175
|
+
justify-content: space-between;
|
176
|
+
}
|
177
|
+
|
178
|
+
.flamegraph-button button {
|
179
|
+
background: var(--grey-200);
|
180
|
+
}
|
data/app/{javascript/stylesheets/traces.scss → assets/stylesheets/rails_mini_profiler/traces.css}
RENAMED
@@ -1,14 +1,19 @@
|
|
1
|
+
/*
|
2
|
+
Place all the styles related to the matching controller here.
|
3
|
+
They will automatically be included in application.css.
|
4
|
+
*/
|
5
|
+
|
1
6
|
.trace-list {
|
2
|
-
padding: 0;
|
3
7
|
margin: 0;
|
8
|
+
padding: 0;
|
4
9
|
}
|
5
10
|
|
6
11
|
.trace {
|
12
|
+
list-style: none;
|
7
13
|
display: flex;
|
14
|
+
padding: .25em 0;
|
8
15
|
align-items: center;
|
9
16
|
justify-content: flex-start;
|
10
|
-
padding: 0.25em 0;
|
11
|
-
list-style: none;
|
12
17
|
}
|
13
18
|
|
14
19
|
.trace:nth-child(odd) {
|
@@ -17,11 +22,11 @@
|
|
17
22
|
|
18
23
|
.trace .trace-bar {
|
19
24
|
position: relative;
|
25
|
+
margin: 0;
|
20
26
|
height: 16px;
|
21
27
|
padding: 0;
|
22
|
-
margin: 0;
|
23
|
-
background: linear-gradient(to top right, var(--grey-500), var(--grey-400));
|
24
28
|
cursor: pointer;
|
29
|
+
background: linear-gradient(to top right, var(--grey-500), var(--grey-400));
|
25
30
|
}
|
26
31
|
|
27
32
|
.instantiation-trace .trace-bar {
|
@@ -42,14 +47,14 @@
|
|
42
47
|
}
|
43
48
|
|
44
49
|
.trace-name {
|
45
|
-
overflow: hidden;
|
46
|
-
box-sizing: border-box;
|
47
|
-
padding: 0 0.5em;
|
48
50
|
margin: 0;
|
49
|
-
|
51
|
+
box-sizing: border-box;
|
52
|
+
padding: 0 .5em;
|
53
|
+
overflow: hidden;
|
50
54
|
font-size: 14px;
|
51
55
|
text-align: right;
|
52
56
|
text-overflow: ellipsis;
|
57
|
+
color: var(--grey-400)
|
53
58
|
}
|
54
59
|
|
55
60
|
.trace-payload {
|
@@ -57,26 +62,26 @@
|
|
57
62
|
}
|
58
63
|
|
59
64
|
.sequel-trace-query {
|
60
|
-
overflow: auto;
|
61
|
-
max-height: 100px;
|
62
65
|
padding: 1em 1em;
|
63
66
|
background: var(--grey-100);
|
67
|
+
overflow: auto;
|
68
|
+
max-height: 100px;
|
64
69
|
white-space: pre-wrap;
|
65
70
|
}
|
66
71
|
|
67
72
|
.sequel-trace-binds {
|
68
|
-
overflow: auto;
|
69
|
-
max-height: 100px;
|
70
|
-
padding: 0.5em 1em;
|
71
73
|
margin: 0 0 1em 0;
|
72
|
-
|
74
|
+
padding: .5em 0;
|
73
75
|
font-size: 12px;
|
76
|
+
overflow: auto;
|
77
|
+
max-height: 100px;
|
74
78
|
white-space: pre-wrap;
|
79
|
+
background: var(--grey-50);
|
75
80
|
}
|
76
81
|
|
77
82
|
.trace-table {
|
78
|
-
width: 100%;
|
79
|
-
border: hidden 1px var(--border-color);
|
80
83
|
margin-top: 1em;
|
84
|
+
width: 100%;
|
81
85
|
border-collapse: collapse;
|
86
|
+
border: hidden 1px var(--border-color);
|
82
87
|
}
|
@@ -1,10 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module RailsMiniProfiler
|
4
|
-
class ApplicationController <
|
5
|
-
|
6
|
-
|
7
|
-
rescue_from ActiveRecord::RecordNotFound, with: ->(error) { handle(error, 404) }
|
4
|
+
class ApplicationController < ::ApplicationController
|
5
|
+
rescue_from ActiveRecord::RecordNotFound, with: :not_found
|
8
6
|
|
9
7
|
before_action :check_current_user
|
10
8
|
|
@@ -19,11 +17,8 @@ module RailsMiniProfiler
|
|
19
17
|
|
20
18
|
private
|
21
19
|
|
22
|
-
def
|
23
|
-
|
24
|
-
format.html { redirect_back(fallback_location: profiled_requests_path, alert: error.to_s) }
|
25
|
-
format.json { render status: status, json: { message: error.to_s } }
|
26
|
-
end
|
20
|
+
def not_found(error)
|
21
|
+
redirect_back(fallback_location: profiled_requests_path, alert: error.to_s)
|
27
22
|
end
|
28
23
|
|
29
24
|
def check_current_user
|
@@ -7,15 +7,16 @@ module RailsMiniProfiler
|
|
7
7
|
before_action :set_profiled_request, only: %i[show destroy]
|
8
8
|
|
9
9
|
def index
|
10
|
-
@profiled_requests = ProfiledRequest
|
11
|
-
|
12
|
-
|
10
|
+
@profiled_requests = ProfiledRequest
|
11
|
+
.includes(:flamegraph)
|
12
|
+
.where(user_id: user_id).order(id: :desc)
|
13
|
+
@profiled_requests = @profiled_requests.where('request_path LIKE ?', "%#{params[:path]}%") if params[:path]
|
13
14
|
@profiled_requests = @profiled_requests.map { |request| present(request) }
|
14
15
|
end
|
15
16
|
|
16
17
|
def show
|
17
18
|
@traces = @profiled_request.traces
|
18
|
-
@traces = @traces.where(
|
19
|
+
@traces = @traces.where('payload LIKE ?', "%#{params[:search]}%") if params[:search]
|
19
20
|
@traces = @traces
|
20
21
|
.order(:start)
|
21
22
|
.map { |trace| present(trace, profiled_request: @profiled_request) }
|
@@ -29,21 +30,16 @@ module RailsMiniProfiler
|
|
29
30
|
|
30
31
|
def destroy_all
|
31
32
|
ProfiledRequest.transaction do
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
profiled_requests.delete_all
|
33
|
+
requests_table_name = RailsMiniProfiler.storage_configuration.profiled_requests_table.to_sym
|
34
|
+
Flamegraph.joins(:profiled_request).where(requests_table_name => { user_id: user_id }).delete_all
|
35
|
+
Trace.joins(:profiled_request).where(requests_table_name => { user_id: user_id }).delete_all
|
36
|
+
ProfiledRequest.where(requests_table_name => { user_id: user_id }).delete_all
|
37
37
|
end
|
38
|
-
redirect_to profiled_requests_url, notice: 'Profiled
|
38
|
+
redirect_to profiled_requests_url, notice: 'Profiled Requests cleared'
|
39
39
|
end
|
40
40
|
|
41
41
|
private
|
42
42
|
|
43
|
-
def index_params
|
44
|
-
params.permit(:path, :duration, id: [], method: [], media_type: [], status: [])
|
45
|
-
end
|
46
|
-
|
47
43
|
def user_id
|
48
44
|
@user_id ||= User.get(request.env)
|
49
45
|
end
|
@@ -55,14 +51,5 @@ module RailsMiniProfiler
|
|
55
51
|
def configuration
|
56
52
|
@configuration ||= RailsMiniProfiler.configuration
|
57
53
|
end
|
58
|
-
|
59
|
-
def payload_column
|
60
|
-
if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
|
61
|
-
# Cast json field to text to have access to the LIKE operator
|
62
|
-
'payload::text'
|
63
|
-
else
|
64
|
-
'payload'
|
65
|
-
end
|
66
|
-
end
|
67
54
|
end
|
68
55
|
end
|
@@ -2,22 +2,11 @@
|
|
2
2
|
|
3
3
|
module RailsMiniProfiler
|
4
4
|
module ApplicationHelper
|
5
|
-
include Pagy::Frontend
|
6
|
-
|
7
5
|
def present(model, presenter_class = nil, **kwargs)
|
8
6
|
klass = presenter_class || "#{model.class}Presenter".constantize
|
9
7
|
presenter = klass.new(model, self, **kwargs)
|
10
8
|
yield(presenter) if block_given?
|
11
9
|
presenter
|
12
10
|
end
|
13
|
-
|
14
|
-
def inline_svg(path, options = {})
|
15
|
-
if defined?(Webpacker::Engine)
|
16
|
-
path = "media/images/#{path}"
|
17
|
-
inline_svg_pack_tag(path, options)
|
18
|
-
else
|
19
|
-
inline_svg_tag(path, options)
|
20
|
-
end
|
21
|
-
end
|
22
11
|
end
|
23
12
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module RailsMiniProfiler
|
4
4
|
class ApplicationRecord < ActiveRecord::Base
|
5
5
|
if RailsMiniProfiler.storage_configuration.database.present?
|
6
|
-
establish_connection(RailsMiniProfiler.storage_configuration.database)
|
6
|
+
establish_connection(RailsMiniProfiler.storage_configuration.database.present?)
|
7
7
|
end
|
8
8
|
|
9
9
|
self.abstract_class = true
|
@@ -7,19 +7,15 @@
|
|
7
7
|
# id :integer not null, primary key
|
8
8
|
# rmp_profiled_request_id :bigint not null
|
9
9
|
# name :string
|
10
|
-
# start :
|
11
|
-
# finish :
|
10
|
+
# start :integer
|
11
|
+
# finish :integer
|
12
12
|
# duration :integer
|
13
|
-
# allocations :
|
13
|
+
# allocations :integer
|
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
|
-
#
|
23
19
|
module RailsMiniProfiler
|
24
20
|
class ControllerTrace < Trace
|
25
21
|
store :payload, accessors: %i[view_runtime db_runtime]
|
@@ -10,10 +10,6 @@
|
|
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
|
-
#
|
17
13
|
module RailsMiniProfiler
|
18
14
|
class Flamegraph < RailsMiniProfiler::ApplicationRecord
|
19
15
|
self.table_name = RailsMiniProfiler.storage_configuration.flamegraphs_table
|
@@ -7,19 +7,15 @@
|
|
7
7
|
# id :integer not null, primary key
|
8
8
|
# rmp_profiled_request_id :bigint not null
|
9
9
|
# name :string
|
10
|
-
# start :
|
11
|
-
# finish :
|
10
|
+
# start :integer
|
11
|
+
# finish :integer
|
12
12
|
# duration :integer
|
13
|
-
# allocations :
|
13
|
+
# allocations :integer
|
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
|
-
#
|
23
19
|
module RailsMiniProfiler
|
24
20
|
class InstantiationTrace < Trace
|
25
21
|
store :payload, accessors: %i[record_count class_name]
|
@@ -4,27 +4,21 @@
|
|
4
4
|
#
|
5
5
|
# Table name: rmp_profiled_requests
|
6
6
|
#
|
7
|
-
# id
|
8
|
-
# user_id
|
9
|
-
# start
|
10
|
-
# finish
|
11
|
-
# duration
|
12
|
-
# allocations
|
13
|
-
# request_path
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
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)
|
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
|
28
22
|
#
|
29
23
|
module RailsMiniProfiler
|
30
24
|
class ProfiledRequest < RailsMiniProfiler::ApplicationRecord
|
@@ -7,19 +7,15 @@
|
|
7
7
|
# id :integer not null, primary key
|
8
8
|
# rmp_profiled_request_id :bigint not null
|
9
9
|
# name :string
|
10
|
-
# start :
|
11
|
-
# finish :
|
10
|
+
# start :integer
|
11
|
+
# finish :integer
|
12
12
|
# duration :integer
|
13
|
-
# allocations :
|
13
|
+
# allocations :integer
|
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
|
-
#
|
23
19
|
module RailsMiniProfiler
|
24
20
|
class RenderPartialTrace < Trace
|
25
21
|
store :payload, accessors: %i[identifier]
|
@@ -7,19 +7,15 @@
|
|
7
7
|
# id :integer not null, primary key
|
8
8
|
# rmp_profiled_request_id :bigint not null
|
9
9
|
# name :string
|
10
|
-
# start :
|
11
|
-
# finish :
|
10
|
+
# start :integer
|
11
|
+
# finish :integer
|
12
12
|
# duration :integer
|
13
|
-
# allocations :
|
13
|
+
# allocations :integer
|
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
|
-
#
|
23
19
|
module RailsMiniProfiler
|
24
20
|
class RenderTemplateTrace < Trace
|
25
21
|
store :payload, accessors: %i[identifier]
|
@@ -7,19 +7,15 @@
|
|
7
7
|
# id :integer not null, primary key
|
8
8
|
# rmp_profiled_request_id :bigint not null
|
9
9
|
# name :string
|
10
|
-
# start :
|
11
|
-
# finish :
|
10
|
+
# start :integer
|
11
|
+
# finish :integer
|
12
12
|
# duration :integer
|
13
|
-
# allocations :
|
13
|
+
# allocations :integer
|
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
|
-
#
|
23
19
|
module RailsMiniProfiler
|
24
20
|
class RmpTrace < Trace
|
25
21
|
class << self
|
@@ -7,19 +7,15 @@
|
|
7
7
|
# id :integer not null, primary key
|
8
8
|
# rmp_profiled_request_id :bigint not null
|
9
9
|
# name :string
|
10
|
-
# start :
|
11
|
-
# finish :
|
10
|
+
# start :integer
|
11
|
+
# finish :integer
|
12
12
|
# duration :integer
|
13
|
-
# allocations :
|
13
|
+
# allocations :integer
|
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
|
-
#
|
23
19
|
module RailsMiniProfiler
|
24
20
|
class SequelTrace < Trace
|
25
21
|
store :payload, accessors: %i[name sql binds]
|
@@ -7,19 +7,15 @@
|
|
7
7
|
# id :integer not null, primary key
|
8
8
|
# rmp_profiled_request_id :bigint not null
|
9
9
|
# name :string
|
10
|
-
# start :
|
11
|
-
# finish :
|
10
|
+
# start :integer
|
11
|
+
# finish :integer
|
12
12
|
# duration :integer
|
13
|
-
# allocations :
|
13
|
+
# allocations :integer
|
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
|
-
#
|
23
19
|
module RailsMiniProfiler
|
24
20
|
class Trace < RailsMiniProfiler::ApplicationRecord
|
25
21
|
self.table_name = RailsMiniProfiler.storage_configuration.traces_table
|
@@ -15,14 +15,21 @@ module RailsMiniProfiler
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def created_at
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
18
|
+
time_tag(model.created_at.in_time_zone(Time.zone))
|
19
|
+
end
|
20
|
+
|
21
|
+
def flamegraph_icon
|
22
|
+
return nil unless RailsMiniProfiler.configuration.flamegraph_enabled
|
23
|
+
|
24
|
+
if model.flamegraph.present?
|
25
|
+
link_to(flamegraph_path(model.id), title: 'Show Flamegraph') do
|
26
|
+
inline_svg_tag('rails_mini_profiler/graph.svg')
|
27
|
+
end
|
28
|
+
else
|
29
|
+
link_to(flamegraph_path(model.id), title: 'No Flamegraph present for this request', class: 'link-disabled') do
|
30
|
+
inline_svg_tag('rails_mini_profiler/graph.svg')
|
31
|
+
end
|
32
|
+
end
|
26
33
|
end
|
27
34
|
|
28
35
|
def flamegraph_button
|
@@ -1,6 +1,17 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
|
-
|
3
|
+
<head>
|
4
|
+
<title>Rails Mini Profiler</title>
|
5
|
+
<%= csrf_meta_tags %>
|
6
|
+
<%= csp_meta_tag %>
|
7
|
+
|
8
|
+
<%= javascript_include_tag "rails_mini_profiler" %>
|
9
|
+
<%= stylesheet_link_tag "rails_mini_profiler/application", media: "all" %>
|
10
|
+
<link rel="preconnect" href="https://fonts.gstatic.com">
|
11
|
+
<script src="https://unpkg.com/@popperjs/core@2"></script>
|
12
|
+
<script src="https://unpkg.com/tippy.js@6"></script>
|
13
|
+
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,400;0,600;0,700;0,800;1,300;1,400;1,600;1,700;1,800&display=swap" rel="stylesheet">
|
14
|
+
</head>
|
4
15
|
<body>
|
5
16
|
|
6
17
|
<%= render 'rails_mini_profiler/shared/navbar' %>
|
@@ -1,6 +1,13 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
|
-
|
3
|
+
<head>
|
4
|
+
<title>Rails Mini Profiler</title>
|
5
|
+
<%= csrf_meta_tags %>
|
6
|
+
<%= csp_meta_tag %>
|
7
|
+
|
8
|
+
<%= javascript_include_tag "rails_mini_profiler" %>
|
9
|
+
<%= stylesheet_link_tag "rails_mini_profiler/application", media: "all" %>
|
10
|
+
</head>
|
4
11
|
<body>
|
5
12
|
|
6
13
|
<main>
|