perf(mcp): 增加 tool 调用全链路往返耗时 debug 日志
记录 roundtrip_ms(含 stdio 传输 + server 派发 + 工具执行 + 回传), 与 server 侧 duration_ms 对比可定位慢在哪一段。
This commit is contained in:
parent
8a4799656c
commit
af344b7087
@ -100,6 +100,7 @@ impl PicoBotTool for McpToolWrapper {
|
||||
}
|
||||
|
||||
async fn execute(&self, args: serde_json::Value) -> anyhow::Result<ToolResult> {
|
||||
let mcp_start = std::time::Instant::now();
|
||||
tracing::debug!(
|
||||
server_key = %self.server_key,
|
||||
tool = %self.tool_name,
|
||||
@ -131,6 +132,15 @@ impl PicoBotTool for McpToolWrapper {
|
||||
call.await?
|
||||
};
|
||||
|
||||
// MCP 全链路往返耗时(含 stdio 传输 + server 派发 + 工具执行 + 回传)。
|
||||
// 与 server 侧 wrapper 进入时间戳、结果内 duration_ms 对比可定位慢在哪一段。
|
||||
tracing::debug!(
|
||||
server_key = %self.server_key,
|
||||
tool = %self.tool_name,
|
||||
roundtrip_ms = mcp_start.elapsed().as_millis() as u64,
|
||||
"MCP tool call finished"
|
||||
);
|
||||
|
||||
// Convert MCP CallToolResult to PicoBot ToolResult
|
||||
let output = extract_text_content(&result);
|
||||
let is_error = result.is_error.unwrap_or(false);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user