dial 0.1.4 → 0.1.5
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/CHANGELOG.md +4 -0
- data/README.md +11 -5
- data/lib/dial/constants.rb +1 -1
- data/lib/dial/middleware/panel.rb +46 -18
- data/lib/dial/middleware.rb +27 -25
- data/lib/dial/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82171550e05c2bc884c0ea9a55e6464f42d9bfef043af62e123c03fdbce943b6
|
4
|
+
data.tar.gz: f7c98017bbcaa66ad376c0b01570007f6b5b70c36ef25843a34254b0e4c82714
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64e51ddaf1029231903836e08c8943afe75df9ec068f4506cba3a85e4c2a5059651af66e8ce3c797132f0ee1943c773abcd52a8ea9fc13fec8280253dbf5dfb3
|
7
|
+
data.tar.gz: cf6d09efec8cd1e581d0b13a91cd6bfce0c1d86612d9b2bf778c01ac6f1766c40fe122eeca19e6133749c396eec2bea34610be2e3d6cd231a4c6eaeebf0d99d6
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -12,18 +12,24 @@ Check out the demo:
|
|
12
12
|
|
13
13
|
## Installation
|
14
14
|
|
15
|
-
1.
|
15
|
+
1. Add the gem to your Rails application's Gemfile (adjust the `require` option to match your server of choice):
|
16
16
|
|
17
|
-
```
|
18
|
-
|
17
|
+
```ruby
|
18
|
+
# require in just the server process
|
19
|
+
gem "dial", require: !!($PROGRAM_NAME =~ /puma/)
|
19
20
|
```
|
20
21
|
|
21
|
-
2.
|
22
|
+
2. Install the gem:
|
23
|
+
|
24
|
+
```bash
|
25
|
+
bundle install
|
26
|
+
```
|
22
27
|
|
28
|
+
3. Mount the engine in your `config/routes.rb` file:
|
23
29
|
|
24
30
|
```ruby
|
25
31
|
# this will mount the engine at /dial
|
26
|
-
mount Dial::Engine, at: "/"
|
32
|
+
mount Dial::Engine, at: "/" if Object.const_defined?("Dial::Engine")
|
27
33
|
```
|
28
34
|
|
29
35
|
## Development
|
data/lib/dial/constants.rb
CHANGED
@@ -6,7 +6,7 @@ module Dial
|
|
6
6
|
REQUEST_TIMING_HEADER = "dial_request_timing"
|
7
7
|
|
8
8
|
PROFILE_OUT_STALE_SECONDS = 60 * 60
|
9
|
-
PROFILE_OUT_RELATIVE_DIRNAME = "tmp/dial/
|
9
|
+
PROFILE_OUT_RELATIVE_DIRNAME = "tmp/dial/profiles/"
|
10
10
|
|
11
11
|
PROSOPITE_IGNORE_QUERIES = [/schema_migrations/]
|
12
12
|
PROSOPITE_LOG_RELATIVE_PATHNAME = "log/dial/prosopite.log"
|
@@ -21,7 +21,16 @@ module Dial
|
|
21
21
|
<span>#{formatted_ruby_version}</span>
|
22
22
|
</div>
|
23
23
|
|
24
|
+
<hr>
|
25
|
+
|
24
26
|
<div id="dial-details">
|
27
|
+
<details>
|
28
|
+
<summary>N+1s</summary>
|
29
|
+
<div class="section query-logs">
|
30
|
+
#{formatted_query_logs query_logs}
|
31
|
+
</div>
|
32
|
+
</details>
|
33
|
+
|
25
34
|
<hr>
|
26
35
|
|
27
36
|
<details>
|
@@ -31,12 +40,7 @@ module Dial
|
|
31
40
|
</div>
|
32
41
|
</details>
|
33
42
|
|
34
|
-
<
|
35
|
-
<summary>N+1s</summary>
|
36
|
-
<div class="section query-logs">
|
37
|
-
#{formatted_query_logs query_logs}
|
38
|
-
</div>
|
39
|
-
</details>
|
43
|
+
<hr>
|
40
44
|
|
41
45
|
<details>
|
42
46
|
<summary>RubyVM stat</summary>
|
@@ -45,6 +49,8 @@ module Dial
|
|
45
49
|
</div>
|
46
50
|
</details>
|
47
51
|
|
52
|
+
<hr>
|
53
|
+
|
48
54
|
<details>
|
49
55
|
<summary>GC stat</summary>
|
50
56
|
<div class="section">
|
@@ -52,6 +58,8 @@ module Dial
|
|
52
58
|
</div>
|
53
59
|
</details>
|
54
60
|
|
61
|
+
<hr>
|
62
|
+
|
55
63
|
<details>
|
56
64
|
<summary>GC stat heap</summary>
|
57
65
|
<div class="section">
|
@@ -70,6 +78,8 @@ module Dial
|
|
70
78
|
def style
|
71
79
|
<<~CSS
|
72
80
|
#dial {
|
81
|
+
max-height: 50%;
|
82
|
+
max-width: 50%;
|
73
83
|
z-index: 9999;
|
74
84
|
position: fixed;
|
75
85
|
bottom: 0;
|
@@ -91,6 +101,7 @@ module Dial
|
|
91
101
|
|
92
102
|
#dial-details {
|
93
103
|
display: none;
|
104
|
+
overflow-y: auto;
|
94
105
|
}
|
95
106
|
|
96
107
|
.section {
|
@@ -104,6 +115,7 @@ module Dial
|
|
104
115
|
|
105
116
|
details {
|
106
117
|
margin-top: 0;
|
118
|
+
margin-bottom: 0.25rem;
|
107
119
|
}
|
108
120
|
}
|
109
121
|
|
@@ -114,6 +126,7 @@ module Dial
|
|
114
126
|
hr {
|
115
127
|
width: -moz-available;
|
116
128
|
margin: 0.65rem 0 0 0;
|
129
|
+
background-color: black;
|
117
130
|
}
|
118
131
|
|
119
132
|
details {
|
@@ -133,10 +146,22 @@ module Dial
|
|
133
146
|
<<~JS
|
134
147
|
const dialPreview = document.getElementById("dial-preview");
|
135
148
|
const dialDetails = document.getElementById("dial-details");
|
149
|
+
|
136
150
|
dialPreview.addEventListener("click", () => {
|
137
151
|
const collapsed = ["", "none"].includes(dialDetails.style.display);
|
138
152
|
dialDetails.style.display = collapsed ? "block" : "none";
|
139
153
|
});
|
154
|
+
|
155
|
+
document.addEventListener("click", (event) => {
|
156
|
+
if (!dialPreview.contains(event.target) && !dialDetails.contains(event.target)) {
|
157
|
+
dialDetails.style.display = "none";
|
158
|
+
|
159
|
+
const detailsElements = dialDetails.querySelectorAll("details");
|
160
|
+
detailsElements.forEach(detail => {
|
161
|
+
detail.removeAttribute("open");
|
162
|
+
});
|
163
|
+
}
|
164
|
+
});
|
140
165
|
JS
|
141
166
|
end
|
142
167
|
|
@@ -178,7 +203,6 @@ module Dial
|
|
178
203
|
def formatted_server_timing server_timing
|
179
204
|
if server_timing.any?
|
180
205
|
server_timing
|
181
|
-
# TODO: Nested sorting
|
182
206
|
.sort_by { |_, timing| -timing }
|
183
207
|
.map { |event, timing| "<span><b>#{event}:</b> #{timing}</span>" }.join
|
184
208
|
else
|
@@ -187,17 +211,21 @@ module Dial
|
|
187
211
|
end
|
188
212
|
|
189
213
|
def formatted_query_logs query_logs
|
190
|
-
query_logs.
|
191
|
-
|
192
|
-
|
193
|
-
<
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
214
|
+
if query_logs.any?
|
215
|
+
query_logs.map do |(queries, stack_lines)|
|
216
|
+
<<~HTML
|
217
|
+
<details>
|
218
|
+
<summary>#{queries.shift}</summary>
|
219
|
+
<div class="section query-logs">
|
220
|
+
#{queries.map { |query| "<span>#{query}</span>" }.join}
|
221
|
+
#{stack_lines.map { |stack_line| "<span>#{stack_line}</span>" }.join}
|
222
|
+
</div>
|
223
|
+
</details>
|
224
|
+
HTML
|
225
|
+
end.join
|
226
|
+
else
|
227
|
+
"NA"
|
228
|
+
end
|
201
229
|
end
|
202
230
|
|
203
231
|
def formatted_ruby_vm_stat ruby_vm_stat
|
data/lib/dial/middleware.rb
CHANGED
@@ -93,32 +93,10 @@ module Dial
|
|
93
93
|
def clear_query_logs!
|
94
94
|
[].tap do |query_logs|
|
95
95
|
File.open(query_log_pathname, "r+") do |file|
|
96
|
-
entry =
|
96
|
+
entry = section = count = nil
|
97
97
|
file.each_line do |line|
|
98
|
-
|
99
|
-
|
100
|
-
entry = [[], []]
|
101
|
-
reading_section = :queries
|
102
|
-
query_count = 0
|
103
|
-
when /Call stack/
|
104
|
-
reading_section = :call_stack
|
105
|
-
if query_count > 5
|
106
|
-
entry.first << "+ #{query_count - 5} more queries"
|
107
|
-
end
|
108
|
-
else
|
109
|
-
case reading_section
|
110
|
-
when :queries
|
111
|
-
query_count += 1
|
112
|
-
entry.first << line.strip if query_count <= 5
|
113
|
-
when :call_stack
|
114
|
-
if line.strip.empty?
|
115
|
-
query_logs << entry
|
116
|
-
reading_section = nil
|
117
|
-
else
|
118
|
-
entry.last << line.strip
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
98
|
+
entry, section, count = process_query_log_line line, entry, section, count
|
99
|
+
query_logs << entry if entry && section.nil?
|
122
100
|
end
|
123
101
|
|
124
102
|
file.truncate 0
|
@@ -127,6 +105,30 @@ module Dial
|
|
127
105
|
end
|
128
106
|
end
|
129
107
|
|
108
|
+
def process_query_log_line line, entry, section, count
|
109
|
+
case line
|
110
|
+
when /N\+1 queries detected/
|
111
|
+
[[[],[]], :queries, 0]
|
112
|
+
when /Call stack/
|
113
|
+
entry.first << "+ #{count - 5} more queries" if count > 5
|
114
|
+
[entry, :call_stack, count]
|
115
|
+
else
|
116
|
+
case section
|
117
|
+
when :queries
|
118
|
+
count += 1
|
119
|
+
entry.first << line.strip if count <= 5
|
120
|
+
[entry, :queries, count]
|
121
|
+
when :call_stack
|
122
|
+
if line.strip.empty?
|
123
|
+
[entry, nil, count]
|
124
|
+
else
|
125
|
+
entry.last << line.strip
|
126
|
+
[entry, section, count]
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
130
132
|
def query_log_pathname
|
131
133
|
@_query_log_dir_pathname ||= ::Rails.root.join PROSOPITE_LOG_RELATIVE_PATHNAME
|
132
134
|
end
|
data/lib/dial/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Young
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 2025-01-24 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: railties
|