Launch Week 02 wrapped — explore all five launches

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

  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>"
    deepeval login
    import deepeval
    
    deepeval.login("<your-confident-api-key>")
  3. Instrument Google ADK

    Call instrument_google_adk once at startup, before your agent runs.

    main.py
    from google.adk.agents import Agent
    from google.adk.runners import Runner
    from google.adk.sessions import InMemorySessionService
    from deepeval.integrations.google_adk import instrument_google_adk
    
    instrument_google_adk()
    
    root_agent = Agent(
        name="my_agent",
        model="gemini-2.0-flash",
        description="A helpful assistant.",
        instruction="Answer questions concisely.",
    )
    
    session_service = InMemorySessionService()
    runner = 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
from google.adk.agents import Agent
from deepeval.integrations.google_adk import instrument_google_adk

instrument_google_adk(
    thread_id="session_abc123",
    user_id="user_1",
)

root_agent = Agent(
    name="my_agent",
    model="gemini-2.0-flash",
    description="A helpful assistant.",
    instruction="Answer questions concisely.",
)

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
from deepeval.integrations.google_adk import instrument_google_adk

instrument_google_adk(
    name="Name of Trace",
    tags=["Tag 1", "Tag 2"],
    metadata={"Key": "Value"},
    user_id="user_1",
    thread_id="session_abc123",
    environment="production",
)
View Trace Attributes

api_keystr

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

namestr

The name of the trace. Learn more.

tagsList[str]

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

metadataDict

Attach any metadata to the trace. Learn more.

thread_idstr

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

user_idstr

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

turn_idstr

The turn ID for multi-turn conversations.

test_case_idstr

Associate this trace with a specific test case ID.

metric_collectionstr

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

environmentstr

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

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
from google.adk.agents import Agent
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from deepeval.prompt import Prompt
from deepeval.tracing import next_llm_span
from deepeval.integrations.google_adk import instrument_google_adk

instrument_google_adk(environment="production")

prompt = Prompt(alias="<prompt-alias>")
prompt.pull(version="00.00.01")

root_agent = Agent(
    name="my_agent",
    model="gemini-2.0-flash",
    description="A helpful assistant.",
    instruction=prompt.interpolate(),
)

session_service = InMemorySessionService()
runner = Runner(agent=root_agent, app_name="my_app", session_service=session_service)

with next_llm_span(prompt=prompt):
    # run your agent here
    pass

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
  2. Run evals

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

    main.py
    from google.adk.agents import Agent
    from deepeval.integrations.google_adk import instrument_google_adk
    
    instrument_google_adk(
        metric_collection="my_metric_collection",
    )
    
    root_agent = Agent(
        name="my_agent",
        model="gemini-2.0-flash",
        description="A helpful assistant.",
        instruction="Answer questions concisely.",
    )

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

Need help wiring this into your stack?Bring traces and evals into the tools your team already usesTalk to an expert
Built byConfident AI