Skip to content

Conversation

@viniciusdsmello
Copy link
Contributor

Pull Request

Summary

Enhanced the Google ADK (Agent Development Kit) tracer with comprehensive callback support, token usage capture, and Google Cloud Trace coexistence. This enables full observability of ADK agents in Openlayer while allowing users to simultaneously send telemetry data to Google Cloud.

Changes

  • Token Usage Capture: Extract and display prompt_tokens, completion_tokens, and total_tokens from LLM responses
  • All 6 ADK Callbacks: Trace all callback types - before_agent, after_agent, before_model, after_model, before_tool, after_tool
  • Google Cloud Trace Coexistence: ADK's built-in OpenTelemetry tracing remains active by default, allowing dual export to both Openlayer and Google Cloud Trace
  • Correct Callback Hierarchy: Callbacks appear in chronological order - before_model appears BEFORE LLM Call, after_model appears AFTER
  • Tool Callback Nesting: Tool callbacks (before_tool, after_tool) are properly nested as siblings of Tool steps within LLM calls
  • Recursive Step Sorting: All nested steps are sorted by start_time to ensure correct chronological display
  • Updated Example Notebook: Added comprehensive example demonstrating all 6 callbacks with proper documentation

Context

Users reported that the Openlayer ADK tracer was not capturing:

  1. Token usage metadata (prompt, completion, total tokens)
  2. Model and tool callbacks (before_model_callback, after_model_callback, before_tool_callback, after_tool_callback)

Additionally, users wanted to use both Google Cloud telemetry (Cloud Trace, Cloud Monitoring) AND Openlayer simultaneously, but the original implementation disabled ADK's OpenTelemetry.

Reference: https://google.github.io/adk-docs/callbacks/

Testing

  • Unit tests
  • Manual testing
  • Postman CI/CD
  • Other

@viniciusdsmello viniciusdsmello changed the title feat(CLOSES open-8261): enhance Google ADK tracing with callback support feat(closes OPEN-8261): enhance Google ADK tracing with callback support Dec 2, 2025
@viniciusdsmello viniciusdsmello self-assigned this Dec 2, 2025
@viniciusdsmello viniciusdsmello added the enhancement New feature or request label Dec 2, 2025
- Add token usage capture (prompt_tokens, completion_tokens, total_tokens)
- Support all 6 ADK callbacks (before/after agent, model, tool)
- Enable Google Cloud Trace coexistence (ADK OTel remains active by default)
- Fix callback hierarchy for correct chronological order
- Add recursive step sorting by start_time
- Update example notebook with comprehensive callback demo
@viniciusdsmello viniciusdsmello force-pushed the vini/open-8261-google-adk-is-not-capturing-the-usage-metadata-tokens-and branch from 1b09c55 to 67021d4 Compare December 2, 2025 16:43
@gustavocidornelas gustavocidornelas merged commit cd601e6 into main Dec 3, 2025
5 checks passed
@gustavocidornelas gustavocidornelas deleted the vini/open-8261-google-adk-is-not-capturing-the-usage-metadata-tokens-and branch December 3, 2025 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants