query_owl 0.4.0 → 0.4.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 +4 -4
- data/app/assets/stylesheets/query_owl/_03_table.css +6 -1
- data/app/views/query_owl/slow_queries/index.html.erb +9 -0
- data/lib/query_owl/configuration.rb +5 -0
- data/lib/query_owl/event_store.rb +1 -1
- data/lib/query_owl/file_logger.rb +4 -0
- data/lib/query_owl/middleware.rb +7 -1
- data/lib/query_owl/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1269c2c24be94cd4ebf8ef07d12fa3e5da1aa2c1573256779f641d3f0a089c6e
|
|
4
|
+
data.tar.gz: 891f6323d6a6ffd95b6e73e131ddbf2f556e90703f5aa67819d92a3bdf0b4ccb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6fe7f83cbb596f8616ffdd11ccea40c4c2c485fa16b303f783a0b6b3a551eef4b8313e353585c8990061832227926738931fa582f9d2de8860b819afad301b96
|
|
7
|
+
data.tar.gz: 87244c9aba6eff9996e97d1f5a3727b8fbf283d6b10647c05fb903d4d7833bc464fdd0c26db84895f8ed7dbc7e290bc6c22f5f225f01360649d03859b9e2dfb7
|
|
@@ -26,4 +26,9 @@
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
.qo-table tr:last-child td { border-bottom: none; }
|
|
29
|
-
.qo-table tr:hover td { background: #fafafa; }
|
|
29
|
+
.qo-table tr:hover td { background: #fafafa; }
|
|
30
|
+
|
|
31
|
+
.qo-table td:nth-child(2) { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
32
|
+
|
|
33
|
+
.qo-request { white-space: nowrap; }
|
|
34
|
+
.qo-path { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 11px; opacity: .7; }
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
<th>Type</th>
|
|
13
13
|
<th>SQL / Details</th>
|
|
14
14
|
<th>Info</th>
|
|
15
|
+
<th>Request</th>
|
|
15
16
|
<th>Recorded At</th>
|
|
16
17
|
<th>Backtrace</th>
|
|
17
18
|
</tr>
|
|
@@ -25,6 +26,14 @@
|
|
|
25
26
|
<% if event[:count] %>count: <%= event[:count] %><% end %>
|
|
26
27
|
<% if event[:duration_ms] %><%= event[:duration_ms] %>ms<% end %>
|
|
27
28
|
</td>
|
|
29
|
+
<td class="qo-request qo-muted">
|
|
30
|
+
<% if event[:controller] || event[:action] %>
|
|
31
|
+
<span class="qo-monospace"><%= [event[:controller], event[:action]].compact.join("#") %></span>
|
|
32
|
+
<% end %>
|
|
33
|
+
<% if event[:path] %>
|
|
34
|
+
<br><span class="qo-path"><%= event[:path] %></span>
|
|
35
|
+
<% end %>
|
|
36
|
+
</td>
|
|
28
37
|
<td class="qo-muted"><%= event[:recorded_at]&.strftime("%H:%M:%S") %></td>
|
|
29
38
|
<td class="qo-monospace qo-muted"><%= Array(event[:backtrace]).first %></td>
|
|
30
39
|
</tr>
|
|
@@ -4,7 +4,7 @@ module QueryOwl
|
|
|
4
4
|
def push(event)
|
|
5
5
|
mutex.synchronize do
|
|
6
6
|
ensure_buffer_size
|
|
7
|
-
buffer[@write_pos] = event.merge(recorded_at: Time.
|
|
7
|
+
buffer[@write_pos] = event.merge(recorded_at: Time.current)
|
|
8
8
|
@write_pos = (@write_pos + 1) % capacity
|
|
9
9
|
@stored = [@stored + 1, capacity].min
|
|
10
10
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "json"
|
|
2
|
+
require "fileutils"
|
|
2
3
|
|
|
3
4
|
module QueryOwl
|
|
4
5
|
class FileLogger
|
|
@@ -9,9 +10,12 @@ module QueryOwl
|
|
|
9
10
|
path = QueryOwl.config.log_file
|
|
10
11
|
return unless path
|
|
11
12
|
|
|
13
|
+
FileUtils.mkdir_p(File.dirname(path))
|
|
12
14
|
File.open(path, "a") do |f|
|
|
13
15
|
events.each { |e| f.puts(JSON.generate(serializable(e))) }
|
|
14
16
|
end
|
|
17
|
+
rescue => e
|
|
18
|
+
Rails.logger.error "[QueryOwl] FileLogger failed: #{e.message}"
|
|
15
19
|
end
|
|
16
20
|
|
|
17
21
|
private
|
data/lib/query_owl/middleware.rb
CHANGED
|
@@ -28,7 +28,13 @@ module QueryOwl
|
|
|
28
28
|
Detector.detect_slow_queries(queries) +
|
|
29
29
|
Detector.detect_unused_eager_loads(eager_data))
|
|
30
30
|
.map { |e| e.merge(context) }
|
|
31
|
-
events.each
|
|
31
|
+
events.each do |event|
|
|
32
|
+
QueryOwl.config.notifiers.each do |notifier|
|
|
33
|
+
notifier.call(event)
|
|
34
|
+
rescue => e
|
|
35
|
+
Rails.logger.error "[QueryOwl] Notifier #{notifier.class} raised: #{e.message}"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
32
38
|
Logger.log_summary(events)
|
|
33
39
|
events.each { |e| EventStore.push(e) }
|
|
34
40
|
FileLogger.append(events)
|
data/lib/query_owl/version.rb
CHANGED