fix: Fixing tracing for function calls#1079
Merged
copybara-service[bot] merged 1 commit intomainfrom Mar 25, 2026
Merged
Conversation
657ba68 to
c621b78
Compare
Fixing when the execute tool happens in the graph. Refactor and simplify the tracing logic for function and tool calls within the ADK. The primary goal is to consolidate multiple tracing events into more cohesive operations, specifically merging "tool_call" and "tool_response" into a single "execute_tool" operation.
### Key Changes:
* **Consolidated Tool Tracing:** Replaced the separate `traceToolCall` and `traceToolResponse` methods with a unified `traceToolExecution` in `Tracing.java`. This reduces span noise by representing a tool's lifecycle as a single "execute_tool" operation containing both arguments and results (or errors).
* **Standardized Operation Names:** Introduced constants for core Gen AI operations: `invoke_agent`, `execute_tool`, `send_data`, and `call_llm`.
* **Improved Error Tracing:** `traceToolExecution` and `traceCallLlm` now explicitly accept an optional `Exception`, allowing them to automatically set the span status to error and record the exception.
* **Refactored Tracing API:**
* `traceSendData` and other methods now require an explicit `Span` argument, moving away from implicit context lookups where appropriate.
* Added `traceMergedToolCalls` to specifically handle the telemetry for parallel tool executions.
* **Flow Logic Cleanup:** Simplified `Functions.java` and `BaseLlmFlow.java` by removing redundant context passing and aligning with the new consolidated tracing methods.
* **Test Suite Updates:** Significantly updated `ContextPropagationTest.java` to reflect the new tracing model. Several manual hierarchy tests were removed in favor of testing the consolidated `execute_tool` logic and updated attributes.
PiperOrigin-RevId: 889246953
c621b78 to
84dff10
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: Fixing tracing for function calls
Fixing when the execute tool happens in the graph. Refactor and simplify the tracing logic for function and tool calls within the ADK. The primary goal is to consolidate multiple tracing events into more cohesive operations, specifically merging "tool_call" and "tool_response" into a single "execute_tool" operation.
Key Changes:
traceToolCallandtraceToolResponsemethods with a unifiedtraceToolExecutioninTracing.java. This reduces span noise by representing a tool's lifecycle as a single "execute_tool" operation containing both arguments and results (or errors).invoke_agent,execute_tool,send_data, andcall_llm.traceToolExecutionandtraceCallLlmnow explicitly accept an optionalException, allowing them to automatically set the span status to error and record the exception.traceSendDataand other methods now require an explicitSpanargument, moving away from implicit context lookups where appropriate.traceMergedToolCallsto specifically handle the telemetry for parallel tool executions.Functions.javaandBaseLlmFlow.javaby removing redundant context passing and aligning with the new consolidated tracing methods.ContextPropagationTest.javato reflect the new tracing model. Several manual hierarchy tests were removed in favor of testing the consolidatedexecute_toollogic and updated attributes.