Skip to content

Feat: Implement tracing for tool execution#453

Closed
AmaadMartin wants to merge 2 commits into
google:mainfrom
AmaadMartin:feat/implement-tool-tracing
Closed

Feat: Implement tracing for tool execution#453
AmaadMartin wants to merge 2 commits into
google:mainfrom
AmaadMartin:feat/implement-tool-tracing

Conversation

@AmaadMartin

Copy link
Copy Markdown
Collaborator

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

  • Closes: #
  • Related: #

2. Or, if no issue exists, describe the change:

Problem:
Tool execution in adk-js was not traced, making it difficult to debug tool calls and performance in production.

Solution:
Wrapped tool execution inside handleFunctionCallList with OpenTelemetry spans. Inlined callToolAsync and simplified event building to ensure the span covers the entire tool execution lifecycle (including callbacks and plugins). Recorded exceptions to the span and set span status to ERROR when appropriate.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Summary of passed npm test results:

 ✓ |unit:core| core/test/agents/functions_test.ts (32 tests)
   ✓ handleFunctionCallList > should execute tool with no callbacks or plugins
   ✓ handleFunctionCallList > should wrap array responses into a {results: array} object
   ✓ handleFunctionCallList > should trace tool execution
   ✓ handleFunctionCallList > should record exception on span when tool throws
   ✓ handleFunctionCallList > should trace merged tool calls when multiple tools executed

Manual End-to-End (E2E) Tests:

N/A

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

N/A

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