Google ADK
Coralogix's AI Observability integration for Google ADK (Agent Development Kit) provides production-ready tracing for agent workflows built on Gemini. Instrument your ADK agents with a single call to gain full visibility into prompts, completions, tool calls, and performance metrics.
What you need
- Python version 3.10 and above.
- Coralogix API keys.
- Google ADK installed and configured with valid credentials.
Installation
Run the following command.
Authentication
Exporting spans to Coralogix requires configuring OTLP credentials before enabling instrumentation. Use setup_export_to_coralogix or the corresponding environment variables to supply authentication details.
Using setup_export_to_coralogix
from llm_tracekit.google_adk import setup_export_to_coralogix
setup_export_to_coralogix(
service_name="ai-service",
application_name="ai-application",
subsystem_name="ai-subsystem",
capture_content=True,
)
Using environment variables
If arguments are not passed to setup_export_to_coralogix, the helper reads the following environment variables:
CX_TOKEN: Your Coralogix API key.CX_ENDPOINT: Select the ingress.:443 endpoint that corresponds to your Coralogix domain using the domain selector at the top of the page.CX_APPLICATION_NAME: Your application's name.CX_SUBSYSTEM_NAME: Your subsystem's name.
Set up tracing
Instrument
Create an instance of GoogleADKInstrumentor and call instrument before running your agent.
Uninstrument
To remove instrumentation, call the uninstrument method.
Full example
import asyncio
from google.adk import Agent, Runner
from google.adk.sessions import InMemorySessionService
from google.genai import types
from llm_tracekit.google_adk import GoogleADKInstrumentor, setup_export_to_coralogix
# Optional: configure sending spans to Coralogix
# Reads connection details from environment variables: CX_TOKEN, CX_ENDPOINT
setup_export_to_coralogix(
service_name="ai-service",
application_name="ai-application",
subsystem_name="ai-subsystem",
capture_content=True,
)
# Activate instrumentation
GoogleADKInstrumentor().instrument()
async def main():
agent = Agent(
name="MyAgent",
model="gemini-2.0-flash",
instruction="You are a helpful assistant.",
)
session_service = InMemorySessionService()
runner = Runner(agent=agent, app_name="my_app", session_service=session_service)
session = await session_service.create_session(app_name="my_app", user_id="user_1")
async for event in runner.run_async(
user_id="user_1",
session_id=session.id,
new_message=types.Content(role="user", parts=[types.Part(text="Hello!")]),
):
if event.content and event.content.parts:
for part in event.content.parts:
if part.text:
print(part.text, end="")
if __name__ == "__main__":
asyncio.run(main())
Enable message content capture
By default, message content — such as prompts, completions, tool call arguments, and tool responses — is not captured.
To capture message content as span attributes, do one of the following:
- Pass
capture_content=Truewhen callingsetup_export_to_coralogix. - Set the environment variable
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENTtotrue.
Many Coralogix AI evaluations rely on message content; enabling capture is a best practice.
Semantic conventions
| Attribute | Type | Description | Example |
|---|---|---|---|
gen_ai.prompt.<message_number>.role | string | Role of the author for each input message | system, user, assistant, tool |
gen_ai.prompt.<message_number>.content | string | Contents of the input message (captured when content capture is enabled) | What's the weather in Paris? |
gen_ai.prompt.<message_number>.tool_calls.<tool_call_number>.id | string | ID of a tool call issued from the prompt | call_O8NOz8VlxosSASEsOY7LDUcP |
gen_ai.prompt.<message_number>.tool_calls.<tool_call_number>.type | string | Type of tool call issued from the prompt | function |
gen_ai.prompt.<message_number>.tool_calls.<tool_call_number>.function.name | string | Function name used in the prompt's tool call | get_current_weather |
gen_ai.prompt.<message_number>.tool_calls.<tool_call_number>.function.arguments | string | Arguments passed to the prompt's tool call | {"location": "Seattle, WA"} |
gen_ai.prompt.<message_number>.tool_call_id | string | Tool call ID in the input message | call_mszuSIzqtI65i1wAUOE8w5H4 |
gen_ai.completion.<choice_number>.role | string | Role of the author for each returned choice | assistant |
gen_ai.completion.<choice_number>.finish_reason | string | Finish reason reported for the choice | stop, tool_calls, error |
gen_ai.completion.<choice_number>.content | string | Text returned by the model (captured when content capture is enabled) | The weather in Paris is rainy and overcast. |
gen_ai.completion.<choice_number>.tool_calls.<tool_call_number>.id | string | ID of a tool call triggered by the model | call_O8NOz8VlxosSASEsOY7LDUcP |
gen_ai.completion.<choice_number>.tool_calls.<tool_call_number>.type | string | Type of tool call triggered by the model | function |
gen_ai.completion.<choice_number>.tool_calls.<tool_call_number>.function.name | string | Function name executed by the model's tool call | get_current_weather |
gen_ai.completion.<choice_number>.tool_calls.<tool_call_number>.function.arguments | string | Arguments supplied to the model's tool call | {"location": "Seattle, WA"} |
gen_ai.request.tools.<tool_number>.type | string | Type of tool entry in tools list | function |
gen_ai.request.tools.<tool_number>.function.name | string | Name of the function used in tool calls | get_current_weather |
gen_ai.request.tools.<tool_number>.function.description | string | Description of the function | Get the current weather in a given location |