Skip to content

Commit 0e997ac

Browse files
lxsaahCopilot
andcommitted
fix(profiling): improve error handling in reset_stage_profiling and update snapshot documentation
Co-authored-by: Copilot <copilot@github.com>
1 parent 9e44017 commit 0e997ac

3 files changed

Lines changed: 11 additions & 13 deletions

File tree

.vscode/mcp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"args": [
1111
"run",
1212
"--manifest-path",
13-
"/aimdb_ws/aimdb/tools/aimdb-mcp/Cargo.toml",
13+
"${workspaceFolder}/tools/aimdb-mcp/Cargo.toml",
1414
"--",
1515
"--socket",
1616
"/tmp/aimdb-demo.sock"

aimdb-core/src/profiling/info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl StageProfilingInfo {
5050

5151
impl RecordProfilingMetrics {
5252
/// Returns a serializable snapshot of every registered stage's metrics,
53-
/// ordered sources → taps → links → transforms.
53+
/// ordered sources → taps → links.
5454
pub fn snapshot(&self) -> Vec<StageProfilingInfo> {
5555
let mut out = Vec::new();
5656
for (kind, stages) in [

tools/aimdb-mcp/src/tools/profiling.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,15 @@ pub async fn reset_stage_profiling(args: Option<Value>) -> McpResult<Value> {
116116
"reset": true,
117117
"message": "Stage profiling counters reset on all records.",
118118
})),
119-
Err(e) => {
120-
// Most likely the server was built without the `profiling` feature.
121-
let msg = e.to_string();
122-
if msg.contains("method_not_found") || msg.contains("Unknown method") {
123-
Ok(json!({
124-
"reset": false,
125-
"message": "The target instance does not support profiling.reset (built without the `profiling` feature?).",
126-
}))
127-
} else {
128-
Err(McpError::Client(e))
129-
}
119+
Err(aimdb_client::ClientError::ServerError { ref code, .. })
120+
if code == "method_not_found" =>
121+
{
122+
// The server was built without the `profiling` feature.
123+
Ok(json!({
124+
"reset": false,
125+
"message": "The target instance does not support profiling.reset (built without the `profiling` feature?).",
126+
}))
130127
}
128+
Err(e) => Err(McpError::Client(e)),
131129
}
132130
}

0 commit comments

Comments
 (0)