Skip to content

fix: Fixing tracing for function calls#1079

Merged
copybara-service[bot] merged 1 commit intomainfrom
test_888632549
Mar 25, 2026
Merged

fix: Fixing tracing for function calls#1079
copybara-service[bot] merged 1 commit intomainfrom
test_888632549

Conversation

@copybara-service
Copy link

@copybara-service copybara-service bot commented Mar 24, 2026

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:

  • 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.

@copybara-service copybara-service bot force-pushed the test_888632549 branch 9 times, most recently from 657ba68 to c621b78 Compare March 25, 2026 14:56
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
@copybara-service copybara-service bot closed this Mar 25, 2026
@copybara-service copybara-service bot merged commit 84dff10 into main Mar 25, 2026
1 check passed
@copybara-service copybara-service bot deleted the test_888632549 branch March 25, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant