Skip to content

Commit 393f1cc

Browse files
committed
Added error status to trace in MCP server for tool calls
Signed-off-by: Felix George <[email protected]>
1 parent d70bea6 commit 393f1cc

File tree

1 file changed

+4
-0
lines changed
  • packages/opentelemetry-instrumentation-mcp/opentelemetry/instrumentation/mcp

1 file changed

+4
-0
lines changed

packages/opentelemetry-instrumentation-mcp/opentelemetry/instrumentation/mcp/instrumentation.py

+4
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ async def send(self, item: Any) -> Any:
250250
span.set_attribute(
251251
SpanAttributes.MCP_RESPONSE_VALUE, f"{serialize(request.result)}"
252252
)
253+
if hasattr(request.result, "isError"):
254+
span.set_status(
255+
Status(StatusCode.ERROR, f"{serialize(request.result)}")
256+
)
253257
if hasattr(request, "id"):
254258
span.set_attribute(SpanAttributes.MCP_REQUEST_ID, f"{request.id}")
255259

0 commit comments

Comments
 (0)