Skip to content

Conversation

@viniciusdsmello
Copy link
Contributor

Pull Request

Summary

This PR adds comprehensive tracing support for Google Agent Development Kit (ADK), enabling Openlayer users to trace agent execution, LLM calls, tool calls, and multi-agent workflows with proper hierarchy and metadata extraction.

Closes OPEN-7119

Changes

  • Core Integration: Added google_adk_tracer.py with support for:

    • Agent execution tracing with sub-agent detection
    • LLM call instrumentation (Gemini models)
    • Tool execution tracking
    • Token usage extraction
    • System instruction handling
    • Session/user ID tracking
  • Smart Agent Nesting: Implemented context variable system to ensure sub-agents appear as siblings of LLM calls (not nested under tool calls), providing cleaner trace hierarchies

  • NoOp Tracer: Replaced ADK's built-in OpenTelemetry tracer to prevent duplicate spans

  • Examples & Documentation:

    • Created interactive Jupyter notebook (google_adk_tracing.ipynb) with multi-agent workflow example
    • Added complete example code with multi-agent system (creator, list videos, choose video, extract text, script, text-to-post agents)
    • Added mock data support for YouTube API and transcript extraction (no API keys needed for demos)
  • Testing: Added 16 comprehensive unit tests covering:

    • Conditional imports
    • NoOp span/tracer behavior
    • Message format conversion
    • LLM attribute extraction
    • Agent metadata extraction
    • Agent transfer handling
    • Tool execution tracing
  • Export: Added trace_google_adk and unpatch_google_adk to __init__.py

  • Documentation: Updated README.md with Google ADK tracing section

Context

Google Agent Development Kit (ADK) is Google's framework for building multi-agent systems with Gemini models. This integration enables Openlayer customers using ADK to:

  1. Monitor Agent Performance: Track agent execution times, LLM calls, and tool usage
  2. Debug Multi-Agent Workflows: Visualize agent transfers and sub-agent hierarchies
  3. Analyze Token Usage: Track prompt/completion tokens across all agent interactions
  4. Session Tracking: Maintain user/session context across agent executions

Key Technical Decisions:

  • Used wrapt for method patching to ensure clean instrumentation
  • Implemented context variables for tracking user queries and agent transfers
  • Skipped tool steps for agent transfers to avoid excessive nesting
  • Created sub-agent steps with explicit parent_step parameter for proper hierarchy

Testing

  • Unit tests
  • Manual testing
  • Postman CI/CD
  • Other (please specify)

@viniciusdsmello viniciusdsmello force-pushed the vini/open-7119-tracing-add-support-for-google-agent-development-kit-adk branch from 4a4a391 to 334f9fb Compare November 6, 2025 17:32
@viniciusdsmello viniciusdsmello marked this pull request as ready for review November 6, 2025 17:32
…ayer

- Add comprehensive Google ADK tracer with support for agents, LLM calls, and tools
- Implement smart agent nesting to avoid excessive hierarchy depth
- Add context variable tracking for agent transfers
- Include interactive Jupyter notebook example
- Add wrapt>=1.14.0 as dependency for method patching
- Export trace_google_adk and unpatch_google_adk functions
@viniciusdsmello viniciusdsmello force-pushed the vini/open-7119-tracing-add-support-for-google-agent-development-kit-adk branch from 334f9fb to cff0f33 Compare November 6, 2025 17:37
@gustavocidornelas gustavocidornelas self-requested a review November 11, 2025 12:26
@gustavocidornelas gustavocidornelas merged commit 89916a8 into main Nov 11, 2025
5 checks passed
@gustavocidornelas gustavocidornelas deleted the vini/open-7119-tracing-add-support-for-google-agent-development-kit-adk branch November 11, 2025 12:29
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.

3 participants