Introducing Confident Monitor

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.

The integration works via OpenTelemetry. ADK already emits its own OpenTelemetry spans for invocations, agents, model calls, and tools; confident-trace, Confident AI's OpenTelemetry-native tracing SDK, picks those spans up and exports them to Confident AI without wrapping the framework.

RuntimeRequirementsSetup
PythonPython 3.10+, google-adk (tested with 2.8.0)Call init() before running the runner
TypeScriptNot supported—

Auto-Instrument

  1. Install Dependencies

    Run the following command to install the required packages:

    pip install confident-trace google-adk
  2. Setup Confident AI Key

    Get your Confident AI Project API key and set it as an environment variable, or pass it to init() directly:

    export CONFIDENT_API_KEY="<your-confident-api-key>"
    export GOOGLE_API_KEY="<your-google-key>"
  3. Instrument Google ADK

    Call init() once at startup, before your runner runs. Keep constructing ADK agents, runners, and sessions as usual.

    main.py
    import asyncio
    
    from confident_trace import init, shutdown
    from google.adk.agents import LlmAgent
    from google.adk.runners import InMemoryRunner
    from google.genai import types
    
    
    async def main():
        init()
        runner = InMemoryRunner(
            app_name="my_app",
            agent=LlmAgent(
                name="my_agent",
                model="gemini-2.5-flash",
                description="A helpful assistant.",
                instruction="Answer questions concisely.",
            ),
        )
        session = await runner.session_service.create_session(
            app_name="my_app", user_id="user-42"
        )
        try:
            async for event in runner.run_async(
                user_id="user-42",
                session_id=session.id,
                new_message=types.Content(
                    role="user", parts=[types.Part(text="What is OpenTelemetry?")]
                ),
            ):
                if event.content and event.content.parts:
                    print(event.content.parts[0].text or "", end="")
            print()
        finally:
            shutdown()
    
    
    asyncio.run(main())
  4. Run your agent

    Invoke your agent by executing the script:

    python main.py

    Done ✅. Open the Observatory in your Confident AI project to inspect the trace.

What Gets Captured

Google ADK runs are exported with their hierarchy intact, so you can follow each invocation through its agents, model calls, and tools.

  • Invocation lifecycle — operation names, timing, status, and session context for each run.
  • Agent execution — which agents participated and the order in which they ran.
  • Model calls — request and response content, model details, finish reasons, and token usage.
  • Tool calls — tool names and their input/output.
  • Errors — failed operations retain their error status in the trace.

Set Trace Span Properties

Use a trace context to add properties you know before the call starts. It creates no extra span; the trace started by runner.run_async() inherits the tags, metadata, user ID, and customer ID.

main.py
from confident_trace import init, trace_context
from google.genai import types

init()

message = types.Content(role="user", parts=[types.Part(text="Explain OpenTelemetry.")])

async with trace_context(
    tags=["support"],
    metadata={"release": "2026-09"},
    user_id="user-42",
    customer_id="customer-7",
):
    async for event in runner.run_async(
        user_id="user-42", session_id=session.id, new_message=message
    ):
        pass

See users and customers to set an optional display name alongside each ID, and trace context for every supported trace property and update behavior.

Instrumenting Multi-Turn

You do not need turn() when one Google ADK entry-point call is already one conversational turn—the integration creates that turn's trace automatically. Use turn() when you want to define the boundary yourself, such as grouping two sequential Google ADK calls into one turn. Reuse the same thread ID on later turns to group them into one conversation.

main.py
from confident_trace import init, turn
from google.genai import types

init()

async with turn("support-turn", thread_id="chat-42"):
    for prompt in ("Find the relevant account details.", "Summarize those details."):
        message = types.Content(role="user", parts=[types.Part(text=prompt)])
        async for event in runner.run_async(
            user_id="user-42", session_id=session.id, new_message=message
        ):
            pass

See threads for thread I/O, turn IDs, and user IDs.

Disable Google ADK Instrumentation

Pass init() a list of integration identifiers to opt in to only those integrations. The identifier for Google ADK is "google_adk" in Python; omit it to disable this integration. An empty list disables all automatic instrumentation:

main.py
from confident_trace import init
init(instrumentations=())
# Use ("google_adk",) to opt in; omit "google_adk" to disable it.

This disables Confident AI's automatic instrumentors. Google ADK may still emit its own native OpenTelemetry spans.

Next Steps

Now that your agent is traced, dive deeper into:

Need help instrumenting your application?Connect your model calls and agent workflows to Confident AITalk to an expert

Last updated on

Built byConfident AI