rails-profiler 0.44.25 → 0.44.27
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/CHANGELOG.md +16 -0
- data/lib/profiler/mcp/server.rb +5 -1
- data/lib/profiler/mcp/tools/query_console_profiles.rb +1 -1
- data/lib/profiler/mcp/tools/query_jobs.rb +1 -1
- data/lib/profiler/mcp/tools/query_mailers.rb +14 -5
- data/lib/profiler/mcp/tools/query_profiles.rb +1 -1
- data/lib/profiler/mcp/tools/query_test_profiles.rb +1 -1
- data/lib/profiler/models/profile.rb +1 -1
- data/lib/profiler/storage/sqlite_store.rb +24 -5
- data/lib/profiler/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: 6f2ed2fe704d2027059860b5738d7a188b8374020aa60041d7121be951b6afdb
|
|
4
|
+
data.tar.gz: 3b6a7bfe912382205fdb7b04a390634c2763805b18f6f41c93dda2d2d9d2aefe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dccc3fb45bcb676d5467e01cead1d205adc52ddde042a9587639b95351300ac622e21ae8db9f2d4a86b255e1ab8b77241bc59d39e26faed7b7c0067172aac60d
|
|
7
|
+
data.tar.gz: 5888e29b8dcccbd98705c36dabfadab10c62bc9e141c4f53b35061c8ea3ecd0d0f7ed70ff217922d676e9282870e2c98f62c767e48b1c8573195fda342a6587c
|
data/CHANGELOG.md
CHANGED
|
@@ -19,6 +19,22 @@ every commit of every tag interval is accounted for one way or the other.
|
|
|
19
19
|
|
|
20
20
|
## [Unreleased]
|
|
21
21
|
|
|
22
|
+
## [0.44.27] - 2026-10-26
|
|
23
|
+
|
|
24
|
+
<!-- stamped -->
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- **MCP tools:** cursor pagination now uses microsecond precision timestamps, so profiles started within the same second are no longer lost between pages. The SQLite store keeps its times with microseconds too (existing rows are padded once on open), and the `query_mailers` cursor carries the position of the last delivery shown so that the deliveries of one request are not dropped at a page boundary.
|
|
29
|
+
|
|
30
|
+
## [0.44.26] - 2026-10-26
|
|
31
|
+
|
|
32
|
+
<!-- stamped -->
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- **MCP:** Reading an unknown resource URI now raises `MCP::Server::ResourceNotFoundError` (JSON-RPC error) instead of returning a success response with nil contents. Refs #73
|
|
37
|
+
|
|
22
38
|
## [0.44.25] - 2026-10-26
|
|
23
39
|
|
|
24
40
|
<!-- stamped -->
|
data/lib/profiler/mcp/server.rb
CHANGED
|
@@ -55,7 +55,11 @@ module Profiler
|
|
|
55
55
|
@server.resources_read_handler do |params|
|
|
56
56
|
uri = params[:uri]
|
|
57
57
|
handler = @resource_handlers[uri]
|
|
58
|
-
|
|
58
|
+
unless handler
|
|
59
|
+
next nil unless defined?(::MCP::Server::ResourceNotFoundError)
|
|
60
|
+
|
|
61
|
+
raise ::MCP::Server::ResourceNotFoundError.new(uri, params)
|
|
62
|
+
end
|
|
59
63
|
|
|
60
64
|
begin
|
|
61
65
|
result = handler.call
|
|
@@ -22,8 +22,9 @@ module Profiler
|
|
|
22
22
|
next unless mailer_data
|
|
23
23
|
|
|
24
24
|
all_emails = Array(mailer_data["emails"]) + Array(mailer_data["errors"])
|
|
25
|
-
all_emails.
|
|
26
|
-
entry = email.merge("profile_token" => profile.token, "profile_started_at" => profile.started_at
|
|
25
|
+
all_emails.each_with_index do |email, index|
|
|
26
|
+
entry = email.merge("profile_token" => profile.token, "profile_started_at" => profile.started_at,
|
|
27
|
+
"profile_index" => index)
|
|
27
28
|
|
|
28
29
|
if params["mailer_class"]
|
|
29
30
|
next unless entry["mailer_class"].to_s.downcase.include?(params["mailer_class"].downcase)
|
|
@@ -49,15 +50,23 @@ module Profiler
|
|
|
49
50
|
end
|
|
50
51
|
|
|
51
52
|
if params["cursor"]
|
|
53
|
+
# "<time>|<n>": the n-th delivery of the profile started at <time> was the last one
|
|
54
|
+
# shown, so the others of that profile (same start time) still come after it.
|
|
55
|
+
time_part, index_part = params["cursor"].to_s.split("|", 2)
|
|
52
56
|
cutoff = begin
|
|
53
|
-
Time.parse(
|
|
57
|
+
Time.parse(time_part)
|
|
54
58
|
rescue ArgumentError, TypeError
|
|
55
59
|
nil # a cursor that is not a time is ignored, as before
|
|
56
60
|
end
|
|
61
|
+
last_index = Integer(index_part, exception: false) if index_part
|
|
57
62
|
if cutoff
|
|
63
|
+
cutoff_key = cutoff.getutc.iso8601(6)
|
|
58
64
|
emails = emails.select do |e|
|
|
59
65
|
started = e["profile_started_at"]
|
|
60
|
-
|
|
66
|
+
next false unless started
|
|
67
|
+
|
|
68
|
+
started < cutoff ||
|
|
69
|
+
(last_index && started.getutc.iso8601(6) == cutoff_key && e["profile_index"] > last_index)
|
|
61
70
|
end
|
|
62
71
|
end
|
|
63
72
|
end
|
|
@@ -109,7 +118,7 @@ module Profiler
|
|
|
109
118
|
if emails.size == limit
|
|
110
119
|
last_started = emails.last["profile_started_at"]
|
|
111
120
|
lines << ""
|
|
112
|
-
lines << "*Next cursor: #{last_started.iso8601}*" if last_started
|
|
121
|
+
lines << "*Next cursor: #{last_started.iso8601(6)}|#{emails.last["profile_index"]}*" if last_started
|
|
113
122
|
end
|
|
114
123
|
|
|
115
124
|
lines.join("\n")
|
|
@@ -149,7 +149,7 @@ module Profiler
|
|
|
149
149
|
duration: @duration,
|
|
150
150
|
allocated_objects: @allocated_objects,
|
|
151
151
|
memory: memory,
|
|
152
|
-
started_at: @started_at&.iso8601,
|
|
152
|
+
started_at: @started_at&.iso8601(6),
|
|
153
153
|
finished_at: @finished_at&.iso8601,
|
|
154
154
|
params: @params,
|
|
155
155
|
params_truncated: @params_truncated,
|
|
@@ -196,7 +196,7 @@ module Profiler
|
|
|
196
196
|
end
|
|
197
197
|
|
|
198
198
|
def cleanup(older_than: 24 * 60 * 60)
|
|
199
|
-
cutoff = (Time.now - older_than).utc.iso8601
|
|
199
|
+
cutoff = (Time.now - older_than).utc.iso8601(6)
|
|
200
200
|
tokens = @db.execute(
|
|
201
201
|
"SELECT token FROM profiler_profiles WHERE started_at < :cutoff", cutoff: cutoff
|
|
202
202
|
).map { |r| r["token"] }
|
|
@@ -323,6 +323,7 @@ module Profiler
|
|
|
323
323
|
|
|
324
324
|
@db.execute("CREATE INDEX IF NOT EXISTS idx_profiler_trace_id ON profiler_profiles(trace_id)")
|
|
325
325
|
migrate_times_to_utc
|
|
326
|
+
migrate_times_to_microseconds
|
|
326
327
|
end
|
|
327
328
|
|
|
328
329
|
# Version 1 stores the times in UTC. The rows written before it carry the local offset of
|
|
@@ -343,6 +344,23 @@ module Profiler
|
|
|
343
344
|
end
|
|
344
345
|
end
|
|
345
346
|
|
|
347
|
+
# Version 2 stores the times with microseconds. As text, "...:00Z" sorts after "...:00.5Z"
|
|
348
|
+
# ('.' < 'Z'), so the rows written without a fraction are padded to the same width.
|
|
349
|
+
def migrate_times_to_microseconds
|
|
350
|
+
return if @db.get_first_value("PRAGMA user_version").to_i >= 2
|
|
351
|
+
|
|
352
|
+
@db.transaction do
|
|
353
|
+
%w[started_at finished_at].each do |column|
|
|
354
|
+
@db.execute(<<~SQL)
|
|
355
|
+
UPDATE profiler_profiles
|
|
356
|
+
SET #{column} = substr(#{column}, 1, length(#{column}) - 1) || '.000000Z'
|
|
357
|
+
WHERE #{column} LIKE '____-__-__T__:__:__Z'
|
|
358
|
+
SQL
|
|
359
|
+
end
|
|
360
|
+
@db.execute("PRAGMA user_version = 2")
|
|
361
|
+
end
|
|
362
|
+
end
|
|
363
|
+
|
|
346
364
|
def row_to_profile(row, load_blobs: true)
|
|
347
365
|
collectors_meta = parse_json(row["collectors_meta"], {})
|
|
348
366
|
|
|
@@ -396,12 +414,13 @@ module Profiler
|
|
|
396
414
|
nil
|
|
397
415
|
end
|
|
398
416
|
|
|
399
|
-
# The times are stored in UTC, all in the same form,
|
|
400
|
-
#
|
|
417
|
+
# The times are stored in UTC, all in the same fixed-width form (microseconds, so profiles
|
|
418
|
+
# started within the same second keep their order and their MCP cursor), for the cleanup and
|
|
419
|
+
# the lists to compare them as text; a profile gives them with the offset of the process that recorded it.
|
|
401
420
|
def utc_iso8601(value)
|
|
402
421
|
return value if value.nil?
|
|
403
422
|
|
|
404
|
-
Time.iso8601(value.to_s).utc.iso8601
|
|
423
|
+
Time.iso8601(value.to_s).utc.iso8601(6)
|
|
405
424
|
rescue ArgumentError
|
|
406
425
|
value
|
|
407
426
|
end
|
|
@@ -410,7 +429,7 @@ module Profiler
|
|
|
410
429
|
def local_iso8601(value)
|
|
411
430
|
return value if value.nil?
|
|
412
431
|
|
|
413
|
-
Time.iso8601(value).localtime.iso8601
|
|
432
|
+
Time.iso8601(value).localtime.iso8601(6)
|
|
414
433
|
rescue ArgumentError
|
|
415
434
|
value
|
|
416
435
|
end
|
data/lib/profiler/version.rb
CHANGED