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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9dd0e38c57b1b0c94a99a0ffb22f6ecc71f0e28c6d4d6d041dac57bc6e5bf626
4
- data.tar.gz: dd6c94c94314dc38da3a757d0e4147dc349ae8842f10e0e29f9fa7fc2e0727ed
3
+ metadata.gz: 1269c2c24be94cd4ebf8ef07d12fa3e5da1aa2c1573256779f641d3f0a089c6e
4
+ data.tar.gz: 891f6323d6a6ffd95b6e73e131ddbf2f556e90703f5aa67819d92a3bdf0b4ccb
5
5
  SHA512:
6
- metadata.gz: be09a0350d981ffcd6e2b5b4e57825daf3d4aca7a0747d0f3579188df22ddc5f26babeab619c24e1d47c0e86ebda1dc1dce99ee65ce32cc01ff1cef1f997a95e
7
- data.tar.gz: 6d499e2d7972b3252f6eccaae8e415f742e2e28b579c08d9e53f2c7377a998a6c5b7be1a46bc3f4189d353258fe7dc0dd01f5df29eb4986d7851c07ad1179fca
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>
@@ -12,6 +12,11 @@ module QueryOwl
12
12
  end
13
13
 
14
14
  def notifiers=(arr)
15
+ arr.each do |notifier|
16
+ unless notifier.respond_to?(:call)
17
+ raise ArgumentError, "notifiers must respond to #call (#{notifier.class} does not)"
18
+ end
19
+ end
15
20
  @notifiers = arr
16
21
  end
17
22
 
@@ -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.now)
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
@@ -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 { |event| QueryOwl.config.notifiers.each { |notifier| notifier.call(event) } }
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)
@@ -1,3 +1,3 @@
1
1
  module QueryOwl
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: query_owl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chuck Smith