Enhanced Distributed Tracing for External MCP Calls
- Lingua principale
- Python
- Stelle
- 21.5k
- Fork
- 4k
- Merge medio
- 1g 14h
- PR unite (30g)
- 37
Descrizione
**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.
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.