rails-profiler 0.44.21 → 0.44.23
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 +19 -0
- data/app/assets/builds/profiler.js +6 -6
- data/lib/profiler/mcp/server.rb +2 -1
- data/lib/profiler/mcp/tools/get_profile_detail.rb +4 -3
- data/lib/profiler/mcp/tools/get_profile_http.rb +5 -4
- data/lib/profiler/tasks/profiler.rake +1 -1
- data/lib/profiler/test_runner/runner.rb +3 -3
- data/lib/profiler/version.rb +1 -1
- metadata +1 -1
data/lib/profiler/mcp/server.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "mcp"
|
|
4
|
+
require "net/http"
|
|
4
5
|
require_relative "http_guard"
|
|
5
6
|
|
|
6
7
|
module Profiler
|
|
@@ -467,7 +468,7 @@ module Profiler
|
|
|
467
468
|
::MCP::Tool.define(name: name, description: description, input_schema: input_schema) do |server_context: nil, **args|
|
|
468
469
|
result = handler.call(args.transform_keys(&:to_s))
|
|
469
470
|
result.is_a?(::MCP::Tool::Response) ? result : ::MCP::Tool::Response.new(result)
|
|
470
|
-
rescue Profiler::Storage::Unavailable::Error, Profiler::Error => e
|
|
471
|
+
rescue Profiler::Storage::Unavailable::Error, Profiler::Error, SystemCallError, Net::OpenTimeout, Net::ReadTimeout => e
|
|
471
472
|
::MCP::Tool::Response.new([{ type: "text", text: e.message }], error: true)
|
|
472
473
|
end
|
|
473
474
|
end
|
|
@@ -400,9 +400,10 @@ module Profiler
|
|
|
400
400
|
if http_data["requests"] && !http_data["requests"].empty?
|
|
401
401
|
lines << "### Request List"
|
|
402
402
|
http_data["requests"].each_with_index do |req, index|
|
|
403
|
-
flag = req["duration"] >= threshold ? " [SLOW]" : ""
|
|
404
|
-
|
|
405
|
-
|
|
403
|
+
flag = (req["duration"] || 0).to_f >= threshold ? " [SLOW]" : ""
|
|
404
|
+
status = req["status"].to_i
|
|
405
|
+
err = status >= 400 || status == 0 ? " [ERROR]" : ""
|
|
406
|
+
lines << "\n**#{index + 1}. #{req['method']} #{req['url']}** - #{status == 0 ? 'error' : status} - #{(req['duration'] || 0).to_f.round(2)} ms#{flag}#{err}"
|
|
406
407
|
|
|
407
408
|
if req["request_body"] && !req["request_body"].empty?
|
|
408
409
|
lines << "**Request Body:**"
|
|
@@ -76,15 +76,16 @@ module Profiler
|
|
|
76
76
|
if requests && !requests.empty?
|
|
77
77
|
lines << "## Request Details"
|
|
78
78
|
requests.each_with_index do |req, i|
|
|
79
|
-
slow_flag = req["duration"] >= threshold ? " [SLOW]" : ""
|
|
80
|
-
|
|
79
|
+
slow_flag = (req["duration"] || 0).to_f >= threshold ? " [SLOW]" : ""
|
|
80
|
+
status = req["status"].to_i
|
|
81
|
+
err_flag = status >= 400 || status == 0 ? " [ERROR]" : ""
|
|
81
82
|
lines << "\n### Request #{i + 1}#{slow_flag}#{err_flag}"
|
|
82
83
|
lines << "- **ID:** #{req['id']}" if req["id"]
|
|
83
84
|
lines << "- **Started at:** #{req['started_at']}" if req["started_at"]
|
|
84
85
|
lines << "- **Method:** #{req['method']}"
|
|
85
86
|
lines << "- **URL:** #{req['url']}"
|
|
86
|
-
lines << "- **Status:** #{
|
|
87
|
-
lines << "- **Duration:** #{req['duration'].round(2)} ms"
|
|
87
|
+
lines << "- **Status:** #{status == 0 ? 'connection error' : status}"
|
|
88
|
+
lines << "- **Duration:** #{(req['duration'] || 0).to_f.round(2)} ms"
|
|
88
89
|
lines << "- **Request Size:** #{req['request_size'].nil? ? 'unknown' : "#{'at least ' if req['request_size_is_minimum']}#{req['request_size']} bytes"}"
|
|
89
90
|
lines << "- **Response Size:** #{req['response_size']} bytes"
|
|
90
91
|
if req["request_body_not_captured"]
|
|
@@ -86,7 +86,7 @@ namespace :profiler do
|
|
|
86
86
|
task mcp: :environment do
|
|
87
87
|
require_relative "../mcp/server"
|
|
88
88
|
|
|
89
|
-
transport = ENV["MCP_TRANSPORT"]&.to_sym ||
|
|
89
|
+
transport = ENV["MCP_TRANSPORT"]&.to_sym || :stdio
|
|
90
90
|
$stderr.puts "Starting Profiler MCP server (#{transport} transport)..."
|
|
91
91
|
|
|
92
92
|
server = Profiler::MCP::Server.new
|
|
@@ -165,11 +165,11 @@ module Profiler
|
|
|
165
165
|
Profiler::TestRunner.run_store.update(run.id, pid: io.pid)
|
|
166
166
|
|
|
167
167
|
begin
|
|
168
|
-
while (chunk = io.
|
|
169
|
-
break if chunk.empty?
|
|
170
|
-
|
|
168
|
+
while (chunk = io.readpartial(4096))
|
|
171
169
|
Profiler::TestRunner.run_store.append_output(run.id, chunk)
|
|
172
170
|
end
|
|
171
|
+
rescue EOFError
|
|
172
|
+
# End of stream reached
|
|
173
173
|
ensure
|
|
174
174
|
# The process printed everything, killed or not: what was held back can be shown.
|
|
175
175
|
Profiler::TestRunner.run_store.finish_output(run.id)
|
data/lib/profiler/version.rb
CHANGED