fix(telemetry): emit Tool.execute span for MCP and plugin tools (#25452)
This commit is contained in:
@@ -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 },
|
{ tool: key, sessionID: ctx.sessionID, callID: opts.toolCallId },
|
||||||
{ args },
|
{ args },
|
||||||
)
|
)
|
||||||
yield* ctx.ask({ permission: key, metadata: {}, patterns: ["*"], always: ["*"] })
|
const result: Awaited<ReturnType<NonNullable<typeof execute>>> = yield* Effect.gen(function* () {
|
||||||
const result: Awaited<ReturnType<NonNullable<typeof execute>>> = yield* Effect.promise(() =>
|
yield* ctx.ask({ permission: key, metadata: {}, patterns: ["*"], always: ["*"] })
|
||||||
execute(args, opts),
|
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(
|
yield* plugin.trigger(
|
||||||
"tool.execute.after",
|
"tool.execute.after",
|
||||||
|
|||||||
@@ -154,7 +154,16 @@ export const layer: Layer.Layer<
|
|||||||
...(out.truncated && { outputPath: out.outputPath }),
|
...(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 } : {}),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user