TraceAI Google ADK Instrumentation
Python auto-instrumentation library for Google ADK.
Quickstart
In this example we will instrument a small program that uses Gemini and observe the traces in Future AGI Dashboard
Install packages.
pip install traceai-google-adk
In a python file, set up the GoogleADKInstrumentor and configure the tracer to send traces to Observe.
import asyncio
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
from google.adk.agents import Agent
from google.adk.runners import InMemoryRunner
from google.genai import types
from traceai_google_adk import GoogleADKInstrumentor
tracer_provider = register(
project_name="test_project",
project_type=ProjectType.OBSERVE,
)
GoogleADKInstrumentor().instrument(tracer_provider=tracer_provider)
def get_weather(city: str) -> dict:
"""Retrieves the current weather report for a specified city.
Args:
city (str): The name of the city for which to retrieve the weather report.
Returns:
dict: status and result or error msg.
"""
if city.lower() == "new york":
return {
"status": "success",
"report": (
"The weather in New York is sunny with a temperature of 25 degrees"
" Celsius (77 degrees Fahrenheit)."
),
}
else:
return {
"status": "error",
"error_message": f"Weather information for '{city}' is not available.",
}
agent = Agent(
name="test_agent",
model="gemini-2.5-flash-preview-05-20",
description="Agent to answer questions using tools.",
instruction="You must use the available tools to find an answer.",
tools=[get_weather],
)
async def main():
app_name = "test_instrumentation"
user_id = "test_user"
session_id = "test_session"
runner = InMemoryRunner(agent=agent, app_name=app_name)
session_service = runner.session_service
await session_service.create_session(
app_name=app_name, user_id=user_id, session_id=session_id
)
async for event in runner.run_async(
user_id=user_id,
session_id=session_id,
new_message=types.Content(
role="user", parts=[types.Part(text="What is the weather in New York?")]
),
):
if event.is_final_response():
print(event.content.parts[0].text.strip())
if __name__ == "__main__":
asyncio.run(main())
Since we are using Gemini, we must set the GOOGLE_API_KEY environment variable to authenticate with the Gemini API.
export GOOGLE_API_KEY=your-api-key
Run the python file to send the traces to Future AGI Platform.
python your_file.py
Release files for traceAI-google-adk 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| traceai_google_adk-0.1.5.tar.gz | 9.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| traceai_google_adk-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.6 kB
Release files / traceai_google_adk-0.1.5.tar.gz
| Download URL | traceai_google_adk-0.1.5.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f4b2099b55836f81f770a462f9661e5305fe3e81945b38b5ad13747578898c10
|
|
BLAKE2b-256 checksum How to use checksums |
b4f07a76a917d76736c8ad59e21b44e64cc5cd77d21c680c5ed2de21079f7f61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.0 CPython/3.13.0 Darwin/25.1.0
|
Release files / traceai_google_adk-0.1.5-py3-none-any.whl
| Download URL | traceai_google_adk-0.1.5-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
afa883fef3c187fbef270a388e55c2d0184aa6d256185ca275b254c97ee4d5ec
|
|
BLAKE2b-256 checksum How to use checksums |
954d3b4ffe3ab5a6b1c07566283e10fc9eda95b0946285d1fb9a401e9e15b913
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.0 CPython/3.13.0 Darwin/25.1.0
|