dial 0.2.4 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c21506e3c567f79104e394c2ab2fc1c29d433ef9e9e27f201d8fe3e6bdc2227f
4
- data.tar.gz: 5a8a65aa3fcdd52d59508ebac6bb12bfa156d6f577793f7c05ac8eb14d5409b3
3
+ metadata.gz: 24787fba428e09eb96323d44b54df1487172d965b47e88df27b1855cefe8e02d
4
+ data.tar.gz: 520e95aae1ac2ca66bb09156a54203a200b94e401c35d269990d43978d2e08cb
5
5
  SHA512:
6
- metadata.gz: c20d37444e2d186490ea5e75d30c2a6940d56adbff21c91d01a448d96b4b7b6baa0ead5da5305a1398dcd8e916f5a9dab60c2d0d101404a1377a998fe2d2d91c
7
- data.tar.gz: 525eef47d8136c0c34ddc0c8460637370e87ea13d43c8d83e1c3b4c9dc992b192414f570a0258a9ffd16206a235611a5450982c3a9cf474f12552c16ef646613
6
+ metadata.gz: dc6187fea22a1334c217461a5b5394ea23f8b1b6c821000ec2629d7537b0986b3626adb16685d4268dd572772fc3fb0ad4eaa4c827faa7c592040258610cad63
7
+ data.tar.gz: bc4ea0f5fabdece3ee0aef7b098035cecc66faad7d5714457b210510a3fa2e3ffd5b08e73ddeebb26f9704817e128f13cc8d2dbf5b03d4eae08b0a60c0d69781
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.5] - 2025-04-04
4
+
5
+ - Perf: Write prosopite logs to IO stream instead of file
6
+ - Remove upper bound on rails dependencies
7
+
3
8
  ## [0.2.4] - 2025-03-03
4
9
 
5
10
  - Add configuration option for setting script CSP nonce (thanks @matthaigh27)
data/README.md CHANGED
@@ -5,7 +5,14 @@
5
5
 
6
6
  WIP
7
7
 
8
- A modern profiler for Rails applications.
8
+ A modern profiler for your Rails application.
9
+
10
+ Utilizes [vernier](https://github.com/jhawthorn/vernier) for profiling and
11
+ [prosopite](https://github.com/charkost/prosopite) for N+1 query detection.
12
+
13
+ > [!NOTE]
14
+ > Check out the resources in the [Vernier](https://github.com/jhawthorn/vernier) project for more information on how to
15
+ > interpret the viewer, as well as comparisons with other profilers, including `stackprof`.
9
16
 
10
17
  Check out the demo:
11
18
  [![Demo](https://img.youtube.com/vi/LPXtfJ0c284/maxresdefault.jpg)](https://youtu.be/LPXtfJ0c284)
@@ -45,14 +52,33 @@ Dial.configure do |config|
45
52
  end
46
53
  ```
47
54
 
48
- ### Options
55
+ ## Options
49
56
 
50
57
  Option | Description | Default
51
- - | - | -
58
+ :- | :- | :-
52
59
  `vernier_interval` | Sets the `interval` option for vernier. | `200`
53
60
  `vernier_allocation_interval` | Sets the `allocation_interval` option for vernier. | `20_000`
54
61
  `prosopite_ignore_queries` | Sets the `ignore_queries` option for prosopite. | `[/schema_migrations/i]`
55
- `content_security_policy_nonce` | Sets the content security policy nonce to use when inserting Dial's script. Can be a string, or a Proc which receives `env` and response `headers` as arguments and returns the nonce. | Rails generated nonce or `nil`
62
+ `content_security_policy_nonce` | Sets the content security policy nonce to use when inserting Dial's script. Can be a string, or a Proc which receives `env` and response `headers` as arguments and returns the nonce string. | Rails generated nonce or `nil`
63
+
64
+ ## Comparison with [rack-mini-profiler](https://github.com/MiniProfiler/rack-mini-profiler)
65
+
66
+ | | rack-mini-profiler | Dial |
67
+ | :------------------------ | :--------------------------------- | :------------------------------------------------------ |
68
+ | Compatibility | Any Rack application | Only Rails applications |
69
+ | Database Profiling | Yes | Yes (via vernier hook - marker table, chart) |
70
+ | N+1 Query Detection | Yes (*needs to be inferred) | Yes (via prosopite) |
71
+ | Ruby Profiling | Yes (with stackprof - flame graph) | Yes (via vernier - flame graph, stack chart, call tree) |
72
+ | Ruby Allocation Profiling | Yes (with stackprof - flame graph) | Yes (via vernier - flame graph, stack chart, call tree) |
73
+ | Memory Profiling | Yes (with memory_profiler) | Yes (*overall usage only) (via vernier hook - graph) |
74
+ | View Profiling | Yes | Yes (via vernier hook - marker table, chart) |
75
+ | Snapshot Sampling | Yes | No |
76
+ | Production Support | Yes | No (WIP) |
77
+
78
+ > [!NOTE]
79
+ > SQL queries displayed in the profile are not annotated with the caller location by default. If you're not using the
80
+ > [marginalia](https://github.com/basecamp/marginalia) gem to annotate your queries, you will need to extend your
81
+ > application's [ActiveRecord QueryLogs](https://edgeapi.rubyonrails.org/classes/ActiveRecord/QueryLogs.html) yourself.
56
82
 
57
83
  ## Development
58
84
 
@@ -69,5 +95,5 @@ The gem is available as open source under the terms of the [MIT License](https:/
69
95
 
70
96
  ## Code of Conduct
71
97
 
72
- Everyone interacting in the Dial project's codebases, issue trackers, chat rooms and mailing lists is expected to follow
73
- the [code of conduct](https://github.com/joshuay03/dial/blob/main/CODE_OF_CONDUCT.md).
98
+ Everyone interacting in the Dial project's codebase and issue tracker is expected to follow the
99
+ [code of conduct](https://github.com/joshuay03/dial/blob/main/CODE_OF_CONDUCT.md).
data/dial.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Joshua Young"]
9
9
  spec.email = ["djry1999@gmail.com"]
10
10
 
11
- spec.summary = "A modern Rails profiler"
11
+ spec.summary = "A modern profiler for your Rails application"
12
12
  spec.homepage = "https://github.com/joshuay03/dial"
13
13
  spec.license = "MIT"
14
14
  spec.required_ruby_version = ">= 3.3.0"
@@ -19,9 +19,9 @@ Gem::Specification.new do |spec|
19
19
  spec.files = Dir["{lib}/**/*", "**/*.{gemspec,md,txt}"]
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency "railties", ">= 7", "< 8.2"
23
- spec.add_dependency "activerecord", ">= 7", "< 8.2"
24
- spec.add_dependency "actionpack", ">= 7", "< 8.2"
22
+ spec.add_dependency "railties", ">= 7"
23
+ spec.add_dependency "activerecord", ">= 7"
24
+ spec.add_dependency "actionpack", ">= 7"
25
25
  spec.add_dependency "vernier"
26
26
  spec.add_dependency "prosopite"
27
27
  spec.add_dependency "pg_query"
@@ -19,8 +19,8 @@ module Dial
19
19
  VERNIER_INTERVAL = 200
20
20
  VERNIER_ALLOCATION_INTERVAL = 20_000
21
21
  VERNIER_PROFILE_OUT_RELATIVE_DIRNAME = "tmp/dial/profiles"
22
+ VERNIER_VIEWER_URL = "https://vernier.prof"
22
23
 
23
24
  PROSOPITE_IGNORE_QUERIES = [/schema_migrations/i].freeze
24
- PROSOPITE_LOG_RELATIVE_DIRNAME = "log/dial"
25
- PROSOPITE_LOG_FILENAME = "#{Util.uuid}_prosopite_#{PROGRAM_ID}.log".freeze
25
+ PROSOPITE_LOG_IO = StringIO.new
26
26
  end
@@ -9,7 +9,7 @@ Dial::Engine.routes.draw do
9
9
  if File.exist? path
10
10
  [
11
11
  200,
12
- { "Content-Type" => "application/json", "Access-Control-Allow-Origin" => "https://vernier.prof" },
12
+ { "Content-Type" => "application/json", "Access-Control-Allow-Origin" => Dial::VERNIER_VIEWER_URL },
13
13
  [File.read(path)]
14
14
  ]
15
15
  else
@@ -88,16 +88,14 @@ module Dial
88
88
 
89
89
  def clear_query_logs!
90
90
  [].tap do |query_logs|
91
- File.open "#{query_log_dir_pathname}/#{PROSOPITE_LOG_FILENAME}", "r+" do |file|
92
- entry = section = count = nil
93
- file.each_line do |line|
94
- entry, section, count = process_query_log_line line, entry, section, count
95
- query_logs << entry if entry && section.nil?
96
- end
97
-
98
- file.truncate 0
99
- file.rewind
91
+ entry = section = count = nil
92
+ PROSOPITE_LOG_IO.string.lines.each do |line|
93
+ entry, section, count = process_query_log_line line, entry, section, count
94
+ query_logs << entry if entry && section.nil?
100
95
  end
96
+
97
+ PROSOPITE_LOG_IO.truncate 0
98
+ PROSOPITE_LOG_IO.rewind
101
99
  end
102
100
  end
103
101
 
@@ -128,9 +126,5 @@ module Dial
128
126
  def profile_out_dir_pathname
129
127
  ::Rails.root.join VERNIER_PROFILE_OUT_RELATIVE_DIRNAME
130
128
  end
131
-
132
- def query_log_dir_pathname
133
- ::Rails.root.join PROSOPITE_LOG_RELATIVE_DIRNAME
134
- end
135
129
  end
136
130
  end
data/lib/dial/railtie.rb CHANGED
@@ -31,16 +31,7 @@ module Dial
31
31
  require "pg_query"
32
32
  end
33
33
 
34
- prosopite_log_pathname = "#{query_log_dir_pathname}/#{PROSOPITE_LOG_FILENAME}"
35
- FileUtils.mkdir_p File.dirname prosopite_log_pathname
36
- FileUtils.touch prosopite_log_pathname
37
- ::Prosopite.custom_logger = ProsopiteLogger.new prosopite_log_pathname
38
- end
39
- end
40
-
41
- initializer "dial.clean_up_prosopite_log_files", after: :load_config_initializers do |app|
42
- stale_files("#{query_log_dir_pathname}/*.log").each do |query_log_file|
43
- File.delete query_log_file rescue nil
34
+ ::Prosopite.custom_logger = ProsopiteLogger.new PROSOPITE_LOG_IO
44
35
  end
45
36
  end
46
37
 
@@ -64,9 +55,5 @@ module Dial
64
55
  def profile_out_dir_pathname
65
56
  ::Rails.root.join VERNIER_PROFILE_OUT_RELATIVE_DIRNAME
66
57
  end
67
-
68
- def query_log_dir_pathname
69
- ::Rails.root.join PROSOPITE_LOG_RELATIVE_DIRNAME
70
- end
71
58
  end
72
59
  end
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.2.4"
4
+ VERSION = "0.2.5"
5
5
  end
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.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Young
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-03-03 00:00:00.000000000 Z
10
+ date: 2025-04-04 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: railties
@@ -16,9 +16,6 @@ dependencies:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
18
  version: '7'
19
- - - "<"
20
- - !ruby/object:Gem::Version
21
- version: '8.2'
22
19
  type: :runtime
23
20
  prerelease: false
24
21
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,9 +23,6 @@ dependencies:
26
23
  - - ">="
27
24
  - !ruby/object:Gem::Version
28
25
  version: '7'
29
- - - "<"
30
- - !ruby/object:Gem::Version
31
- version: '8.2'
32
26
  - !ruby/object:Gem::Dependency
33
27
  name: activerecord
34
28
  requirement: !ruby/object:Gem::Requirement
@@ -36,9 +30,6 @@ dependencies:
36
30
  - - ">="
37
31
  - !ruby/object:Gem::Version
38
32
  version: '7'
39
- - - "<"
40
- - !ruby/object:Gem::Version
41
- version: '8.2'
42
33
  type: :runtime
43
34
  prerelease: false
44
35
  version_requirements: !ruby/object:Gem::Requirement
@@ -46,9 +37,6 @@ dependencies:
46
37
  - - ">="
47
38
  - !ruby/object:Gem::Version
48
39
  version: '7'
49
- - - "<"
50
- - !ruby/object:Gem::Version
51
- version: '8.2'
52
40
  - !ruby/object:Gem::Dependency
53
41
  name: actionpack
54
42
  requirement: !ruby/object:Gem::Requirement
@@ -56,9 +44,6 @@ dependencies:
56
44
  - - ">="
57
45
  - !ruby/object:Gem::Version
58
46
  version: '7'
59
- - - "<"
60
- - !ruby/object:Gem::Version
61
- version: '8.2'
62
47
  type: :runtime
63
48
  prerelease: false
64
49
  version_requirements: !ruby/object:Gem::Requirement
@@ -66,9 +51,6 @@ dependencies:
66
51
  - - ">="
67
52
  - !ruby/object:Gem::Version
68
53
  version: '7'
69
- - - "<"
70
- - !ruby/object:Gem::Version
71
- version: '8.2'
72
54
  - !ruby/object:Gem::Dependency
73
55
  name: vernier
74
56
  requirement: !ruby/object:Gem::Requirement
@@ -157,5 +139,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
139
  requirements: []
158
140
  rubygems_version: 3.6.2
159
141
  specification_version: 4
160
- summary: A modern Rails profiler
142
+ summary: A modern profiler for your Rails application
161
143
  test_files: []