Skip to content

Commit 8fee2fe

Browse files
committed
fix(otel): mark client span ERROR with tool_error when tools/call returns isError (#3810)
1 parent 77001c9 commit 8fee2fe

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎src/mcp/shared/jsonrpc_dispatcher.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,9 @@ async def send_raw_request(
418418
code = str(outcome.code)
419419
span.set_attributes({"error.type": code, "rpc.response.status_code": code})
420420
span.set_status(StatusCode.ERROR, outcome.message)
421+
elif method == "tools/call" and isinstance(outcome, Mapping) and outcome.get("isError") is True:
422+
span.set_attribute("error.type", "tool_error")
423+
span.set_status(StatusCode.ERROR)
421424
except TimeoutError:
422425
if not timeout_armed:
423426
# The clock starts only after the write, so this TimeoutError is the

0 commit comments

Comments
 (0)