rails_mini_profiler 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.
Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +220 -0
  3. data/Rakefile +18 -0
  4. data/app/assets/config/rails_mini_profiler_manifest.js +1 -0
  5. data/app/assets/images/rails_mini_profiler/bookmark.svg +10 -0
  6. data/app/assets/images/rails_mini_profiler/chart.svg +12 -0
  7. data/app/assets/images/rails_mini_profiler/delete.svg +9 -0
  8. data/app/assets/images/rails_mini_profiler/graph.svg +11 -0
  9. data/app/assets/images/rails_mini_profiler/logo.svg +18 -0
  10. data/app/assets/images/rails_mini_profiler/logo_variant.svg +32 -0
  11. data/app/assets/images/rails_mini_profiler/search.svg +10 -0
  12. data/app/assets/images/rails_mini_profiler/setting.svg +10 -0
  13. data/app/assets/images/rails_mini_profiler/show.svg +11 -0
  14. data/app/assets/javascripts/rails_mini_profiler.js +90 -0
  15. data/app/assets/stylesheets/rails_mini_profiler/application.css +164 -0
  16. data/app/assets/stylesheets/rails_mini_profiler/flamegraph.css +14 -0
  17. data/app/assets/stylesheets/rails_mini_profiler/flashes.css +17 -0
  18. data/app/assets/stylesheets/rails_mini_profiler/navbar.css +50 -0
  19. data/app/assets/stylesheets/rails_mini_profiler/profiled_requests.css +180 -0
  20. data/app/assets/stylesheets/rails_mini_profiler/traces.css +87 -0
  21. data/app/controllers/rails_mini_profiler/application_controller.rb +28 -0
  22. data/app/controllers/rails_mini_profiler/flamegraphs_controller.rb +23 -0
  23. data/app/controllers/rails_mini_profiler/profiled_requests_controller.rb +55 -0
  24. data/app/helpers/rails_mini_profiler/application_helper.rb +12 -0
  25. data/app/helpers/rails_mini_profiler/profiled_requests_helper.rb +16 -0
  26. data/app/models/rails_mini_profiler/application_record.rb +17 -0
  27. data/app/models/rails_mini_profiler/controller_trace.rb +33 -0
  28. data/app/models/rails_mini_profiler/flamegraph.rb +33 -0
  29. data/app/models/rails_mini_profiler/instantiation_trace.rb +33 -0
  30. data/app/models/rails_mini_profiler/profiled_request.rb +59 -0
  31. data/app/models/rails_mini_profiler/render_partial_trace.rb +33 -0
  32. data/app/models/rails_mini_profiler/render_template_trace.rb +33 -0
  33. data/app/models/rails_mini_profiler/rmp_trace.rb +31 -0
  34. data/app/models/rails_mini_profiler/sequel_trace.rb +33 -0
  35. data/app/models/rails_mini_profiler/trace.rb +42 -0
  36. data/app/presenters/rails_mini_profiler/base_presenter.rb +25 -0
  37. data/app/presenters/rails_mini_profiler/controller_trace_presenter.rb +18 -0
  38. data/app/presenters/rails_mini_profiler/instantiation_trace_presenter.rb +14 -0
  39. data/app/presenters/rails_mini_profiler/profiled_request_presenter.rb +45 -0
  40. data/app/presenters/rails_mini_profiler/render_partial_trace_presenter.rb +11 -0
  41. data/app/presenters/rails_mini_profiler/render_template_trace_presenter.rb +15 -0
  42. data/app/presenters/rails_mini_profiler/rmp_trace_presenter.rb +9 -0
  43. data/app/presenters/rails_mini_profiler/sequel_trace_presenter.rb +69 -0
  44. data/app/presenters/rails_mini_profiler/trace_presenter.rb +61 -0
  45. data/app/views/layouts/rails_mini_profiler/application.html.erb +26 -0
  46. data/app/views/layouts/rails_mini_profiler/flamegraph.html.erb +18 -0
  47. data/app/views/rails_mini_profiler/badge.html.erb +37 -0
  48. data/app/views/rails_mini_profiler/flamegraphs/show.html.erb +13 -0
  49. data/app/views/rails_mini_profiler/profiled_requests/index.html.erb +59 -0
  50. data/app/views/rails_mini_profiler/profiled_requests/shared/_trace.html.erb +40 -0
  51. data/app/views/rails_mini_profiler/profiled_requests/show.html.erb +40 -0
  52. data/app/views/rails_mini_profiler/shared/_flashes.html.erb +8 -0
  53. data/app/views/rails_mini_profiler/shared/_navbar.html.erb +15 -0
  54. data/config/routes.rb +11 -0
  55. data/db/migrate/20210621185018_create_rmp.rb +44 -0
  56. data/lib/generators/rails_mini_profiler/USAGE +2 -0
  57. data/lib/generators/rails_mini_profiler/install_generator.rb +16 -0
  58. data/lib/generators/rails_mini_profiler/templates/rails_mini_profiler.rb.erb +13 -0
  59. data/lib/rails_mini_profiler.rb +55 -0
  60. data/lib/rails_mini_profiler/badge.rb +62 -0
  61. data/lib/rails_mini_profiler/configuration.rb +41 -0
  62. data/lib/rails_mini_profiler/engine.rb +23 -0
  63. data/lib/rails_mini_profiler/errors.rb +8 -0
  64. data/lib/rails_mini_profiler/flamegraph_guard.rb +47 -0
  65. data/lib/rails_mini_profiler/guard.rb +46 -0
  66. data/lib/rails_mini_profiler/logger.rb +20 -0
  67. data/lib/rails_mini_profiler/middleware.rb +74 -0
  68. data/lib/rails_mini_profiler/models/base_model.rb +18 -0
  69. data/lib/rails_mini_profiler/models/trace.rb +9 -0
  70. data/lib/rails_mini_profiler/redirect.rb +25 -0
  71. data/lib/rails_mini_profiler/request_context.rb +62 -0
  72. data/lib/rails_mini_profiler/request_wrapper.rb +33 -0
  73. data/lib/rails_mini_profiler/response_wrapper.rb +32 -0
  74. data/lib/rails_mini_profiler/storage.rb +29 -0
  75. data/lib/rails_mini_profiler/tracers.rb +85 -0
  76. data/lib/rails_mini_profiler/user.rb +40 -0
  77. data/lib/rails_mini_profiler/version.rb +5 -0
  78. data/lib/tasks/rails_mini_profiler_tasks.rake +8 -0
  79. metadata +151 -0
@@ -0,0 +1,164 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
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; }
@@ -0,0 +1,17 @@
1
+ .flash {
2
+ margin-top: 1rem;
3
+ padding: 1rem 1rem;
4
+
5
+ border-radius: 5px;
6
+ }
7
+
8
+ .flash-error {
9
+ color: white;
10
+ background: var(--red-500);
11
+ }
12
+
13
+ .flash-notice {
14
+ color: white;
15
+ background: var(--green-400);
16
+
17
+ }
@@ -0,0 +1,50 @@
1
+ .header {
2
+ margin: 0;
3
+ padding: 1.5rem 0;
4
+
5
+ display: flex;
6
+ justify-content: center;
7
+
8
+ box-shadow: 0 0 20px 0 rgba(0,0,0,.2);
9
+
10
+ background: var(--primary);
11
+ }
12
+
13
+ .header a {
14
+ color:white;
15
+ text-decoration: none;
16
+ }
17
+
18
+ .nav {
19
+ width: var(--main-width);
20
+
21
+ display: flex;
22
+ justify-content: space-between;
23
+ }
24
+
25
+ .home {
26
+ display: flex;
27
+ align-items: center;
28
+
29
+ text-decoration: none;
30
+ }
31
+
32
+ .home-logo {
33
+ width: 64px;
34
+ height: 64px;
35
+ }
36
+
37
+ .home-title {
38
+ padding: 0 0 0 1rem;
39
+ margin: 0;
40
+ }
41
+
42
+ .header-links {
43
+ margin: 0;
44
+ padding: 0;
45
+ list-style: none;
46
+ display: flex;
47
+ align-items: center;
48
+
49
+ font-weight: 700;
50
+ }
@@ -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
+ }
@@ -0,0 +1,87 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
5
+
6
+ .trace-list {
7
+ margin: 0;
8
+ padding: 0;
9
+ }
10
+
11
+ .trace {
12
+ list-style: none;
13
+ display: flex;
14
+ padding: .25em 0;
15
+ align-items: center;
16
+ justify-content: flex-start;
17
+ }
18
+
19
+ .trace:nth-child(odd) {
20
+ background: var(--grey-100);
21
+ }
22
+
23
+ .trace .trace-bar {
24
+ position: relative;
25
+ margin: 0;
26
+ height: 16px;
27
+ padding: 0;
28
+ cursor: pointer;
29
+ background: linear-gradient(to top right, var(--grey-500), var(--grey-400));
30
+ }
31
+
32
+ .instantiation-trace .trace-bar {
33
+ background: linear-gradient(to top right, var(--green-400), var(--green-300));
34
+ }
35
+
36
+ .sequel-trace .trace-bar {
37
+ background: linear-gradient(to top right, var(--green-500), var(--green-400));
38
+ }
39
+
40
+ .controller-trace .trace-bar {
41
+ background: linear-gradient(to top right, var(--yellow-500), var(--yellow-400));
42
+ }
43
+
44
+ .render-template-trace .trace-bar,
45
+ .render-partial-trace .trace-bar {
46
+ background: linear-gradient(to top right, var(--blue-500), var(--blue-400));
47
+ }
48
+
49
+ .trace-name {
50
+ margin: 0;
51
+ box-sizing: border-box;
52
+ padding: 0 .5em;
53
+ overflow: hidden;
54
+ font-size: 14px;
55
+ text-align: right;
56
+ text-overflow: ellipsis;
57
+ color: var(--grey-400)
58
+ }
59
+
60
+ .trace-payload {
61
+ margin: 0;
62
+ }
63
+
64
+ .sequel-trace-query {
65
+ padding: 1em 1em;
66
+ background: var(--grey-100);
67
+ overflow: auto;
68
+ max-height: 100px;
69
+ white-space: pre-wrap;
70
+ }
71
+
72
+ .sequel-trace-binds {
73
+ margin: 0 0 1em 0;
74
+ padding: .5em 0;
75
+ font-size: 12px;
76
+ overflow: auto;
77
+ max-height: 100px;
78
+ white-space: pre-wrap;
79
+ background: var(--grey-50);
80
+ }
81
+
82
+ .trace-table {
83
+ margin-top: 1em;
84
+ width: 100%;
85
+ border-collapse: collapse;
86
+ border: hidden 1px var(--border-color);
87
+ }