Google ADK

Use Confident AI for LLM observability and evals for Google ADK

Overview

Google ADK (Agent Development Kit) is Google’s open-source framework for building, evaluating, and deploying AI agents. Confident AI allows you to trace and evaluate Google ADK agents in just a few lines of code.

The integration works via OpenTelemetry: instrument_google_adk() wraps the community-maintained openinference-instrumentation-google-adk package, which instruments every ADK agent, model call, and tool invocation as an OTel span. Confident AI’s OpenInference span interceptor then translates these into Confident AI spans and ships them in real time.

Tracing Quickstart

For users in the EU region, please set the OTEL endpoint to the EU version:

$export CONFIDENT_OTEL_URL="https://eu.otel.confident-ai.com"
1

Install Dependencies

Run the following command to install the required packages:

$pip install -U deepeval google-adk openinference-instrumentation-google-adk opentelemetry-sdk opentelemetry-exporter-otlp-proto-http
2

Setup Confident AI Key

Login to Confident AI using your Confident API key.

$export CONFIDENT_API_KEY="<your-confident-api-key>"
3

Instrument Google ADK

Call instrument_google_adk once at startup, before your agent runs.

main.py
1from google.adk.agents import Agent
2from google.adk.runners import Runner
3from google.adk.sessions import InMemorySessionService
4from deepeval.integrations.google_adk import instrument_google_adk
5
6instrument_google_adk()
7
8root_agent = Agent(
9 name="my_agent",
10 model="gemini-2.0-flash",
11 description="A helpful assistant.",
12 instruction="Answer questions concisely.",
13)
14
15session_service = InMemorySessionService()
16runner = Runner(agent=root_agent, app_name="my_app", session_service=session_service)
4

Run your agent

Invoke your agent by executing the script:

$python main.py

You can view the traces on Confident AI by clicking on the link printed in the console.

Advanced Usage

Logging threads

Threads group related traces together and are useful for chat apps, agents, or any multi-turn interactions. You can learn more about threads here. Pass the thread_id to instrument_google_adk.

main.py
1from google.adk.agents import Agent
2from deepeval.integrations.google_adk import instrument_google_adk
3
4instrument_google_adk(
5 thread_id="session_abc123",
6 user_id="user_1",
7)
8
9root_agent = Agent(
10 name="my_agent",
11 model="gemini-2.0-flash",
12 description="A helpful assistant.",
13 instruction="Answer questions concisely.",
14)

Trace attributes

Other trace-level attributes can be passed to instrument_google_adk. All parameters are optional and apply to every trace produced while the instrumentation is active.

main.py
1from deepeval.integrations.google_adk import instrument_google_adk
2
3instrument_google_adk(
4 name="Name of Trace",
5 tags=["Tag 1", "Tag 2"],
6 metadata={"Key": "Value"},
7 user_id="user_1",
8 thread_id="session_abc123",
9 environment="production",
10)
api_key
str

Your Confident AI API key. Defaults to the CONFIDENT_API_KEY environment variable when omitted.

name
str

The name of the trace. Learn more.

tags
List[str]

Tags are string labels that help you group related traces. Learn more.

metadata
Dict

Attach any metadata to the trace. Learn more.

thread_id
str

Supply the thread or conversation ID to view and evaluate conversations. Learn more.

user_id
str

Supply the user ID to enable user analytics. Learn more.

turn_id
str

The turn ID for multi-turn conversations.

test_case_id
str

Associate this trace with a specific test case ID.

metric_collection
str

The name of the metric collection to use for online evals at the trace level.

environment
str

The deployment environment. Accepted values: "production", "staging", "development", "testing". Defaults to "development".

Each attribute is optional, and works the same way as the native tracing features on Confident AI.

Logging prompts

If you are managing prompts on Confident AI and wish to log them, use next_llm_span to associate a Prompt with the next LLM span before invoking your agent.

main.py
1from google.adk.agents import Agent
2from google.adk.runners import Runner
3from google.adk.sessions import InMemorySessionService
4from deepeval.prompt import Prompt
5from deepeval.tracing import next_llm_span
6from deepeval.integrations.google_adk import instrument_google_adk
7
8instrument_google_adk(environment="production")
9
10prompt = Prompt(alias="<prompt-alias>")
11prompt.pull(version="00.00.01")
12
13root_agent = Agent(
14 name="my_agent",
15 model="gemini-2.0-flash",
16 description="A helpful assistant.",
17 instruction=prompt.interpolate(),
18)
19
20session_service = InMemorySessionService()
21runner = Runner(agent=root_agent, app_name="my_app", session_service=session_service)
22
23with next_llm_span(prompt=prompt):
24 # run your agent here
25 pass

Be sure to pull the prompt before logging it, otherwise the prompt will not be visible on Confident AI.

Evals Usage

Online evals

You can run online evals on your Google ADK agent, which will run evaluations on all incoming traces on Confident AI’s servers. This approach is recommended if your agent is in production.

1

Create metric collection

Create a metric collection on Confident AI with the metrics you wish to use to evaluate your agent.

Create metric collection

Your metric collection should only contain metrics that evaluate the input and output of the span or trace you are targeting.

2

Run evals

Pass metric_collection to instrument_google_adk to evaluate every trace produced by your agent.

main.py
1from google.adk.agents import Agent
2from deepeval.integrations.google_adk import instrument_google_adk
3
4instrument_google_adk(
5 metric_collection="my_metric_collection",
6)
7
8root_agent = Agent(
9 name="my_agent",
10 model="gemini-2.0-flash",
11 description="A helpful assistant.",
12 instruction="Answer questions concisely.",
13)

All incoming traces will now be evaluated using metrics from your metric collection.

You can view eval results on Confident AI by clicking on the link printed in the console.