google / google/adk-python

Enhanced Distributed Tracing for External MCP Calls

オープン
#3,063 コメント 2 件 リアクション 1 件 担当者 2 名 @klateefa が担当を希望しています GitHub で見る
mcp needs review tracing
主要言語
Python
スター
21.5k
フォーク
4k
平均マージ
1日 14時間
マージ済み PR(30日)
37

説明

**Please make sure you read the contribution guide and file the issues in the right place.**
[Contribution guide.](https://google.github.io/adk-docs/contributing-guide/)

**Is your feature request related to a problem? Please describe.**
I am unable to effectively monitor and debug the latency of external services invoked by an ADK agent using the Model Context Protocol.

When an agent calls a remote tool (e.g., `execute_tool_echo`), the trace only shows a span for the ADK internal execution step (`execute_tool_echo`). It fails to generate a downstream child span that represents the actual outbound HTTP/RPC request to the external MCP server endpoint.

**Describe the solution you'd like**
I would like the ADK's MCP client implementation to ensure full distributed tracing visibility when making calls to external MCP servers.

Specifically, the ADK framework should guarantee the following for every outbound MCP network request:

1. Span Creation: A dedicated child span must be created immediately before the network request is initiated. This span should accurately reflect the client-side call to the external tool service and be a direct child of the current `execute_tool_[tool_name]` span.
2. Dependency Identification: The new span must be annotated with standard telemetry attributes (metadata) required to identify the external service being called (e.g., service address and request URL) to enable accurate dependency mapping in APM systems.
3. Context Propagation: The ADK client must reliably propagate the active OpenTelemetry trace context by injecting the required headers into the outbound MCP request, allowing the remote MCP server to continue the trace correctly.

**Describe alternatives you've considered**
I have attempted to solve this using programmatic instrumentation by installing and enabling all common OpenTelemetry client instrumentors:
- opentelemetry-instrumentation-requests
- opentelemetry-instrumentation-httpx
- opentelemetry-instrumentation-urllib3
- opentelemetry-instrumentation-urllib
- opentelemetry-instrumentation-grpc
- opentelemetry-instrumentation-aiohttp-client

**Additional context**
Full distributed tracing for external MCP calls fundamentally transforms the agent's performance troubleshooting workflow. Currently, developers face a frustrating "black box" scenario, where tool execution time is visible (`execute_tool_echo`), but the cause of that delay (network, external service processing) is hidden. Implementing this feature would allow for immediate root-cause analysis, providing clear, visual confirmation of where bottlenecks lie.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。