Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions py/src/braintrust/integrations/adk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ def setup_adk(
"""
Setup Braintrust integration with Google ADK. Will automatically patch Google ADK agents, runners, flows, and MCP tools for automatic tracing.

Also enables the Google GenAI integration, which ADK's Gemini models call
through. It owns the ``llm`` span and token usage for each Gemini request;
ADK's ``llm_call`` spans are ``task`` spans so usage is counted once. For
other ADK models (e.g. LiteLLM or Anthropic), enable that provider's
integration, or use ``braintrust.auto_instrument()``, to record usage.

If you prefer manual patching take a look at `wrap_agent`, `wrap_runner`, `wrap_workflow`, `wrap_flow`, and `wrap_mcp_tool`.

Args:
Expand All @@ -61,4 +67,7 @@ def setup_adk(
if span == NOOP_SPAN:
init_logger(project=project_name, api_key=api_key, project_id=project_id)

from braintrust.integrations.google_genai import GoogleGenAIIntegration

GoogleGenAIIntegration.setup()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid patching GenAI when ADK setup fails

When google-genai is installed but google-adk is absent or outside the supported version range, this call still globally patches Google GenAI before ADKIntegration.setup() returns False. A caller that uses the return value to treat ADK instrumentation as unavailable will therefore unexpectedly trace unrelated direct GenAI calls; enable the provider integration only after confirming that ADK setup succeeded.

Useful? React with 👍 / 👎.

return ADKIntegration.setup()

This file was deleted.

Loading
Loading