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