# Google ADK

Google's Agent Development Kit (ADK) accelerates the path from prototype to production for generative AI agents. The framework bundles orchestration, tracing, and agent management into a unified package, reducing the infrastructure work typically required when building agent systems.

This guide covers capturing telemetry from ADK applications using InteractiveAI and OpenTelemetry instrumentation.

### Prerequisites

* InteractiveAI account with API credentials
* Google Gemini API key

***

### Installation

```bash
pip install interactiveai google-adk openinference-instrumentation-google-adk
```

***

### Configuration

Set your API credentials as environment variables:

```python
import os

# InteractiveAI credentials
os.environ["INTERACTIVEAI_PUBLIC_KEY"] = "pk-..."
os.environ["INTERACTIVEAI_SECRET_KEY"] = "sk-..."

# Google API key
os.environ["GOOGLE_API_KEY"] = "..."
```

Initialize the client and confirm connectivity:

```python
from interactiveai import Interactive

interactiveai = Interactive(
    public_key=os.environ["INTERACTIVEAI_PUBLIC_KEY"],
    secret_key=os.environ["INTERACTIVEAI_SECRET_KEY"],
)

if interactiveai.auth_check():
    print("Connection established")
else:
    print("Authentication failed - verify credentials")
```

***

### Enabling Trace Capture

Google ADK has a dedicated OpenInference instrumentor that captures agent operations automatically:

```python
from openinference.instrumentation.google_adk import GoogleADKInstrumentor

GoogleADKInstrumentor().instrument()
```

Once activated, tool calls and model completions generate spans that route to InteractiveAI.

***

### Running an ADK Agent

Here's a functional example with a simple tool-equipped agent:

```python
from google.adk.agents import Agent
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.genai import types

def get_current_time():
    return {"time": "14:32 UTC"}

agent = Agent(
    name="time_agent",
    model="gemini-2.0-flash",
    instruction="Always respond with the current time using the get_current_time tool.",
    tools=[get_current_time],
)

APP_NAME = "time_app"
USER_ID = "demo-user"
SESSION_ID = "demo-session"

session_service = InMemorySessionService()
await session_service.create_session(app_name=APP_NAME, user_id=USER_ID, session_id=SESSION_ID)

runner = Runner(agent=agent, app_name=APP_NAME, session_service=session_service)

user_msg = types.Content(role="user", parts=[types.Part(text="What time is it?")])
for event in runner.run(user_id=USER_ID, session_id=SESSION_ID, new_message=user_msg):
    if event.is_final_response():
        print(event.content.parts[0].text)
```

Each tool invocation and model response appears as a distinct span in InteractiveAI.

***

### Enriching Traces with Context

Combine OpenInference instrumentation with the InteractiveAI SDK to attach identifiers and metadata:

<pre class="language-python"><code class="lang-python">from interactiveai import Interactive
from google.adk.agents import Agent
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.genai import types

interactiveai = Interactive(
    public_key=os.environ["INTERACTIVEAI_PUBLIC_KEY"],
    secret_key=os.environ["INTERACTIVEAI_SECRET_KEY"],
)

with interactiveai.start_as_current_span(name="adk-agent-task") as span:
    
<strong>    interactiveai.update_current_trace(
</strong><strong>        user_id="user_google_adk",
</strong><strong>        session_id="session_google_adk",
</strong><strong>        tags=["google-adk", "gemini"],
</strong><strong>        metadata={"experiment": "baseline", "environment": "production"}
</strong><strong>    )
</strong>    
    # ADK agent execution here
    # ...
    
    interactiveai.update_current_trace(
        input="User query",
        output="Agent response"
    )

interactiveai.flush()
</code></pre>

***

### Trace Visibility

The InteractiveAI dashboard displays:

* Agent execution flow and tool invocations
* Model requests with prompts and completions
* Token consumption and latency metrics
* Session and user context for each trace
