(result: ExecuteResult)
| 92 | const executeOutcomeAttributesCache = new WeakMap<ExecuteResult, Record<string, unknown>>(); |
| 93 | |
| 94 | const executeOutcomeAttributes = (result: ExecuteResult): Record<string, unknown> => { |
| 95 | const cached = executeOutcomeAttributesCache.get(result); |
| 96 | if (cached) return cached; |
| 97 | const attributes = { |
| 98 | "mcp.execute.result_chars": measureResultChars(result.result), |
| 99 | "mcp.execute.log_chars": result.logs?.reduce((total, line) => total + line.length, 0) ?? 0, |
| 100 | "mcp.execute.emitted": result.output?.length ?? 0, |
| 101 | ...(result.error |
| 102 | ? { "mcp.execute.outcome": "fail", "mcp.execute.error_kind": result.errorKind ?? "unknown" } |
| 103 | : { "mcp.execute.outcome": "ok" }), |
| 104 | }; |
| 105 | executeOutcomeAttributesCache.set(result, attributes); |
| 106 | return attributes; |
| 107 | }; |
| 108 | |
| 109 | /** |
| 110 | * Stamp the current `mcp.execute` / `mcp.execute.resume` span with how the |
no test coverage detected