Google ADK (tracing)
Google Agent Development Kit (ADK) is a framework for building agents with tools and multi-agent workflows. Respan captures ADK runner, agent, LLM, and tool spans, then exports them through the Respan tracing pipeline.
This tracing setup uses your Google model credentials directly through ADK. To route model calls through Respan instead, use the Google ADK gateway setup .
Set up Respan
Create an account at platform.respan.ai and grab an API key .
Paste this into your coding agent:
Help me set up Respan tracing with the Google ADK integration.
Follow https://www.respan.ai/docs/integrations/google-adk.mdSetup
Install packages
pip install respan-ai respan-instrumentation-google-adk "google-adk[extensions]"Set environment variables
export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY"
export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"GOOGLE_API_KEY is used by ADK for direct model requests. RESPAN_API_KEY exports traces to Respan.
Initialize and run
import asyncio
from google.adk.agents import Agent
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.genai import types
from respan import Respan
from respan_instrumentation_google_adk import GoogleADKInstrumentor
respan = Respan(instrumentations=[GoogleADKInstrumentor()])
agent = Agent(
name="assistant",
model="gemini-2.0-flash",
instruction="You are a concise assistant.",
)
async def main():
session_service = InMemorySessionService()
session = await session_service.create_session(
app_name="google-adk-demo",
user_id="user_1",
)
runner = Runner(
agent=agent,
app_name="google-adk-demo",
session_service=session_service,
)
message = types.Content(
role="user",
parts=[types.Part(text="Say hello in one sentence.")],
)
async for event in runner.run_async(
user_id="user_1",
session_id=session.id,
new_message=message,
):
if event.is_final_response():
print(event.content.parts[0].text)
respan.shutdown()
asyncio.run(main())View your trace
Open the Traces page to see ADK runner, agent, model, and tool spans.
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key / apiKey | str | None / string | undefined | RESPAN_API_KEY | Respan API key used to export traces. |
base_url / baseURL | str | None / string | undefined | RESPAN_BASE_URL | Optional Respan trace export API URL. |
instrumentations | list / RespanInstrumentation[] | [] | Include GoogleADKInstrumentor() or new GoogleADKInstrumentor() to activate Google ADK tracing. |
Attributes
In Respan()
Set defaults at initialization. These apply to all spans from the instrumented ADK run.
from respan import Respan
from respan_instrumentation_google_adk import GoogleADKInstrumentor
respan = Respan(
instrumentations=[GoogleADKInstrumentor()],
customer_identifier="user_123",
metadata={"service": "adk-api", "version": "1.0.0"},
)With propagate_attributes
Override per-request attributes using a context scope.
from respan import Respan, propagate_attributes
from respan_instrumentation_google_adk import GoogleADKInstrumentor
respan = Respan(instrumentations=[GoogleADKInstrumentor()])
async def handle_request(user_id: str, message: str):
with propagate_attributes(
customer_identifier=user_id,
thread_identifier="conv_abc_123",
metadata={"plan": "pro"},
):
output = await run_agent_once(message)
return output| Attribute | Type | Description |
|---|---|---|
customer_identifier | str / string | Identifies the end user in Respan analytics. |
thread_identifier | str / string | Groups related messages into a conversation. |
metadata | dict / Record<string, unknown> | Custom key-value pairs. |
Captured spans
- ADK runner invocations as workflow spans
- Agent invocations as agent spans
- Model calls as chat spans with prompts, completions, tool definitions, and token fields
- Tool executions as tool spans with normalized input and output