rails-profiler 0.26.0 → 0.27.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/builds/profiler-toolbar.js +2888 -72
- data/app/assets/builds/profiler.js +3887 -513
- data/lib/profiler/mcp/resources/recent_console.rb +36 -0
- data/lib/profiler/mcp/server.rb +53 -10
- data/lib/profiler/mcp/tools/clear_profiles.rb +3 -3
- data/lib/profiler/mcp/tools/get_profile_detail.rb +123 -1
- data/lib/profiler/mcp/tools/get_profile_mailers.rb +147 -0
- data/lib/profiler/mcp/tools/query_console_profiles.rb +95 -0
- data/lib/profiler/storage/file_store.rb +36 -22
- data/lib/profiler/version.rb +1 -1
- metadata +5 -2
|
@@ -7,10 +7,13 @@ require_relative "../models/profile"
|
|
|
7
7
|
|
|
8
8
|
module Profiler
|
|
9
9
|
module Storage
|
|
10
|
+
# File-based profile storage backend. Persists each profile as a JSON file
|
|
11
|
+
# under tmp_path and evicts the oldest files when total size exceeds max_size.
|
|
10
12
|
class FileStore < BaseStore
|
|
11
13
|
def initialize(options = {})
|
|
14
|
+
super()
|
|
12
15
|
@path = options[:path] || default_path
|
|
13
|
-
@max_size = options[:max_size] || 100 * 1024 * 1024 # 100 MB
|
|
16
|
+
@max_size = options[:max_size] || (100 * 1024 * 1024) # 100 MB
|
|
14
17
|
ensure_directory_exists
|
|
15
18
|
end
|
|
16
19
|
|
|
@@ -27,7 +30,7 @@ module Profiler
|
|
|
27
30
|
|
|
28
31
|
json_data = File.read(file_path)
|
|
29
32
|
Models::Profile.from_json(json_data)
|
|
30
|
-
rescue => e
|
|
33
|
+
rescue StandardError => e
|
|
31
34
|
warn "Failed to load profile #{token}: #{e.message}"
|
|
32
35
|
nil
|
|
33
36
|
end
|
|
@@ -46,8 +49,8 @@ module Profiler
|
|
|
46
49
|
cutoff_time = Time.now - older_than
|
|
47
50
|
profile_files.each do |file|
|
|
48
51
|
File.delete(file) if File.mtime(file) < cutoff_time
|
|
49
|
-
rescue
|
|
50
|
-
|
|
52
|
+
rescue Errno::ENOENT
|
|
53
|
+
nil
|
|
51
54
|
end
|
|
52
55
|
end
|
|
53
56
|
|
|
@@ -56,22 +59,25 @@ module Profiler
|
|
|
56
59
|
.map { |f| load(File.basename(f, ".json")) }
|
|
57
60
|
.compact
|
|
58
61
|
.select { |profile| profile.parent_token == parent_token }
|
|
59
|
-
.sort_by
|
|
62
|
+
.sort_by(&:started_at)
|
|
60
63
|
end
|
|
61
64
|
|
|
62
65
|
def delete(token)
|
|
63
|
-
|
|
64
|
-
File.delete(file_path) if File.exist?(file_path)
|
|
66
|
+
FileUtils.rm_f(profile_file_path(token))
|
|
65
67
|
end
|
|
66
68
|
|
|
67
|
-
def clear(type: nil)
|
|
69
|
+
def clear(type: nil) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
68
70
|
if type.nil?
|
|
69
|
-
profile_files.each
|
|
71
|
+
profile_files.each do |f|
|
|
72
|
+
File.delete(f)
|
|
73
|
+
rescue StandardError
|
|
74
|
+
nil
|
|
75
|
+
end
|
|
70
76
|
else
|
|
71
77
|
profile_files.each do |f|
|
|
72
78
|
profile = load(File.basename(f, ".json"))
|
|
73
79
|
File.delete(f) if profile&.profile_type == type.to_s
|
|
74
|
-
rescue
|
|
80
|
+
rescue StandardError
|
|
75
81
|
nil
|
|
76
82
|
end
|
|
77
83
|
end
|
|
@@ -95,20 +101,28 @@ module Profiler
|
|
|
95
101
|
Dir.glob(File.join(@path, "*.json"))
|
|
96
102
|
end
|
|
97
103
|
|
|
98
|
-
def cleanup_if_needed
|
|
99
|
-
total_size = profile_files.sum
|
|
104
|
+
def cleanup_if_needed # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
105
|
+
total_size = profile_files.sum do |f|
|
|
106
|
+
File.size(f)
|
|
107
|
+
rescue Errno::ENOENT
|
|
108
|
+
0
|
|
109
|
+
end
|
|
100
110
|
return if total_size < @max_size
|
|
101
111
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
+
sorted = profile_files.sort_by do |f|
|
|
113
|
+
File.mtime(f)
|
|
114
|
+
rescue Errno::ENOENT
|
|
115
|
+
Time.now
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
sorted.each do |file|
|
|
119
|
+
file_size = File.size(file)
|
|
120
|
+
File.delete(file)
|
|
121
|
+
total_size -= file_size
|
|
122
|
+
break if total_size < @max_size * 0.8
|
|
123
|
+
rescue Errno::ENOENT
|
|
124
|
+
nil
|
|
125
|
+
end
|
|
112
126
|
end
|
|
113
127
|
end
|
|
114
128
|
end
|
data/lib/profiler/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails-profiler
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.27.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sébastien Duplessy
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-06-
|
|
11
|
+
date: 2026-06-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -165,6 +165,7 @@ files:
|
|
|
165
165
|
- lib/profiler/mcp/path_extractor.rb
|
|
166
166
|
- lib/profiler/mcp/resources/failing_tests.rb
|
|
167
167
|
- lib/profiler/mcp/resources/n1_patterns.rb
|
|
168
|
+
- lib/profiler/mcp/resources/recent_console.rb
|
|
168
169
|
- lib/profiler/mcp/resources/recent_jobs.rb
|
|
169
170
|
- lib/profiler/mcp/resources/recent_requests.rb
|
|
170
171
|
- lib/profiler/mcp/resources/slow_queries.rb
|
|
@@ -178,8 +179,10 @@ files:
|
|
|
178
179
|
- lib/profiler/mcp/tools/get_profile_detail.rb
|
|
179
180
|
- lib/profiler/mcp/tools/get_profile_dumps.rb
|
|
180
181
|
- lib/profiler/mcp/tools/get_profile_http.rb
|
|
182
|
+
- lib/profiler/mcp/tools/get_profile_mailers.rb
|
|
181
183
|
- lib/profiler/mcp/tools/get_test_profile_detail.rb
|
|
182
184
|
- lib/profiler/mcp/tools/list_env_vars.rb
|
|
185
|
+
- lib/profiler/mcp/tools/query_console_profiles.rb
|
|
183
186
|
- lib/profiler/mcp/tools/query_jobs.rb
|
|
184
187
|
- lib/profiler/mcp/tools/query_mailers.rb
|
|
185
188
|
- lib/profiler/mcp/tools/query_profiles.rb
|