summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authorKit Langton <[email protected]>2026-05-02 14:49:56 -0400
committerGitHub <[email protected]>2026-05-02 14:49:56 -0400
commit6cd02c05c26958ef87ab6d00a2215fb8ade95e3f (patch)
tree295f647edc961967d5b2ec8cacefa835af7a82c3 /packages
parentb3a75137654b844b6260d2ddf804affac4000475 (diff)
downloadopencode-6cd02c05c26958ef87ab6d00a2215fb8ade95e3f.tar.gz
opencode-6cd02c05c26958ef87ab6d00a2215fb8ade95e3f.zip
fix(telemetry): emit Tool.execute span for MCP and plugin tools (#25452)
Diffstat (limited to 'packages')
-rw-r--r--packages/opencode/src/session/prompt.ts15
-rw-r--r--packages/opencode/src/tool/registry.ts11
2 files changed, 22 insertions, 4 deletions
diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts
index fb822ff17..80c47d3ce 100644
--- a/packages/opencode/src/session/prompt.ts
+++ b/packages/opencode/src/session/prompt.ts
@@ -464,9 +464,18 @@ NOTE: At any point in time through this workflow you should feel free to ask the
{ tool: key, sessionID: ctx.sessionID, callID: opts.toolCallId },
{ args },
)
- yield* ctx.ask({ permission: key, metadata: {}, patterns: ["*"], always: ["*"] })
- const result: Awaited<ReturnType<NonNullable<typeof execute>>> = yield* Effect.promise(() =>
- execute(args, opts),
+ const result: Awaited<ReturnType<NonNullable<typeof execute>>> = yield* Effect.gen(function* () {
+ yield* ctx.ask({ permission: key, metadata: {}, patterns: ["*"], always: ["*"] })
+ return yield* Effect.promise(() => execute(args, opts))
+ }).pipe(
+ Effect.withSpan("Tool.execute", {
+ attributes: {
+ "tool.name": key,
+ "tool.call_id": opts.toolCallId,
+ "session.id": ctx.sessionID,
+ "message.id": input.processor.message.id,
+ },
+ }),
)
yield* plugin.trigger(
"tool.execute.after",
diff --git a/packages/opencode/src/tool/registry.ts b/packages/opencode/src/tool/registry.ts
index a9a853e50..ebe3bb530 100644
--- a/packages/opencode/src/tool/registry.ts
+++ b/packages/opencode/src/tool/registry.ts
@@ -154,7 +154,16 @@ export const layer: Layer.Layer<
...(out.truncated && { outputPath: out.outputPath }),
},
}
- }),
+ }).pipe(
+ Effect.withSpan("Tool.execute", {
+ attributes: {
+ "tool.name": id,
+ "session.id": toolCtx.sessionID,
+ "message.id": toolCtx.messageID,
+ ...(toolCtx.callID ? { "tool.call_id": toolCtx.callID } : {}),
+ },
+ }),
+ ),
}
}