dial 0.3.0 → 0.3.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: 42f0f94ef6fdc4992e56f9b1938f464916c2ac36ded2ae17a506fc3798cda278
4
- data.tar.gz: 05e9b4db37fa643be44ca3b9800d44ecc79dbe1b69209d4978e13de1dbec82d6
3
+ metadata.gz: c57fbfd8d0f023bcfd0606a5d61cfe84dd7b93d618dd844d50332b576dcce3d5
4
+ data.tar.gz: 27db795cf357bd7c878ea939c9c66374cc50f54e304466f91b9add37e0535a95
5
5
  SHA512:
6
- metadata.gz: 6f071e302b7b7f83395a3f4e796d9b8cb3b99138dcd9b67c7cabfd57dea537d197266e01f4789644c06c482b72badc6f6c858bb28913631959c9255ebf162536
7
- data.tar.gz: f6782c98fde560a03f29aa95bdae546e1d1aae0388b6a2403617d229d15cebe3d4ab2d36d606a4ede4b5b4ff43c9f9690336716865b22eb526b9a706f98906a0
6
+ metadata.gz: ea4ba198fd052cdfed3a35d95a5424f6da32c94da85dec1cad9d78edd6b92e336d35afa76704349c5ef0475ac8a60f9ba90026b753109f4a0cea8caba994d3c4
7
+ data.tar.gz: 4d1578a97dd8439a4e6060698d24a0605f9747fd471d47844dd5f981f257790a00ecd4a5ed097377ef3af6d61062dd0b76d6023f5fd5dca0990a8f2642421c5a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.1] - 2025-05-03
4
+
5
+ - Only show truncated summary + one full query in N+1 logs
6
+ - Fix parsing of multiline N+1 query logs
7
+ - Truncate summary N+1 queries to 100 chars
8
+
3
9
  ## [0.3.0] - 2025-05-02
4
10
 
5
11
  - Require rails 7.1.0 or later
@@ -11,6 +11,7 @@ module Dial
11
11
 
12
12
  HTTP_ACCEPT = "HTTP_ACCEPT"
13
13
  CONTENT_TYPE = ::Rack::CONTENT_TYPE
14
+ CONTENT_TYPE_HTML = "text/html"
14
15
  CONTENT_LENGTH = ::Rack::CONTENT_LENGTH
15
16
  NONCE = ::ActionDispatch::ContentSecurityPolicy::Request::NONCE
16
17
  REQUEST_TIMING = "dial_request_timing"
@@ -4,6 +4,8 @@ require "uri"
4
4
 
5
5
  module Dial
6
6
  class Panel
7
+ QUERY_CHARS_TRUNCATION_THRESHOLD = 100
8
+
7
9
  class << self
8
10
  def html env, headers, profile_out_filename, query_logs, ruby_vm_stat, gc_stat, gc_stat_heap, server_timing
9
11
  <<~HTML
@@ -223,7 +225,7 @@ module Dial
223
225
  query_logs.map do |(queries, stack_lines)|
224
226
  <<~HTML
225
227
  <details>
226
- <summary>#{queries.shift}</summary>
228
+ <summary>#{truncated_query queries.first}</summary>
227
229
  <div class="section query-logs">
228
230
  #{queries.map { |query| "<span>#{query}</span>" }.join}
229
231
  #{stack_lines.map { |stack_line| "<span>#{stack_line}</span>" }.join}
@@ -236,6 +238,12 @@ module Dial
236
238
  end
237
239
  end
238
240
 
241
+ def truncated_query query
242
+ return query if query.length <= QUERY_CHARS_TRUNCATION_THRESHOLD
243
+
244
+ query[0...QUERY_CHARS_TRUNCATION_THRESHOLD] + "..."
245
+ end
246
+
239
247
  def formatted_ruby_vm_stat ruby_vm_stat
240
248
  ruby_vm_stat.map { |key, value| "<span><b>#{key}:</b> #{value}</span>" }.join
241
249
  end
@@ -12,14 +12,12 @@ module Dial
12
12
  include RubyStat
13
13
  include RailsStat
14
14
 
15
- HTML_CONTENT_TYPE = "text/html"
16
-
17
15
  def initialize app
18
16
  @app = app
19
17
  end
20
18
 
21
19
  def call env
22
- unless env[HTTP_ACCEPT]&.include? HTML_CONTENT_TYPE
20
+ unless env[HTTP_ACCEPT]&.include? CONTENT_TYPE_HTML
23
21
  return @app.call env
24
22
  end
25
23
 
@@ -40,7 +38,7 @@ module Dial
40
38
  end
41
39
  server_timing = server_timing headers
42
40
 
43
- unless headers[CONTENT_TYPE]&.include? HTML_CONTENT_TYPE
41
+ unless headers[CONTENT_TYPE]&.include? CONTENT_TYPE_HTML
44
42
  return [status, headers, rack_body]
45
43
  end
46
44
 
@@ -106,13 +104,13 @@ module Dial
106
104
  when /N\+1 queries detected/
107
105
  [[[],[]], :queries, 0]
108
106
  when /Call stack/
109
- entry.first << "+ #{count - 5} more queries" if count > 5
107
+ entry.first << "+ #{count - 1} more queries" if count > 1
110
108
  [entry, :call_stack, count]
111
109
  else
112
110
  case section
113
111
  when :queries
114
112
  count += 1
115
- entry.first << line.strip if count <= 5
113
+ entry.first << line.strip if count == 1
116
114
  [entry, :queries, count]
117
115
  when :call_stack
118
116
  if line.strip.empty?
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dial
4
+ module Prosopite
5
+ def send_notifications
6
+ tc[:prosopite_notifications] = tc[:prosopite_notifications].to_h do |queries, kaller|
7
+ [queries.map { |query| query.squish }, kaller]
8
+ end
9
+
10
+ super
11
+ end
12
+ end
13
+ end
14
+
15
+ module ::Prosopite
16
+ class << self
17
+ prepend Dial::Prosopite
18
+ end
19
+ end
data/lib/dial/railtie.rb CHANGED
@@ -4,6 +4,7 @@ require "rails"
4
4
  require "active_record"
5
5
  require "prosopite"
6
6
 
7
+ require_relative "prosopite"
7
8
  require_relative "middleware"
8
9
  require_relative "prosopite_logger"
9
10
 
data/lib/dial/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dial
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dial
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Young
@@ -113,6 +113,7 @@ files:
113
113
  - lib/dial/middleware/panel.rb
114
114
  - lib/dial/middleware/rails_stat.rb
115
115
  - lib/dial/middleware/ruby_stat.rb
116
+ - lib/dial/prosopite.rb
116
117
  - lib/dial/prosopite_logger.rb
117
118
  - lib/dial/railtie.rb
118
119
  - lib/dial/util.rb