Registry / observability / openinference-instrumentation-google-adk

openinference-instrumentation-google-adk

JSON →
library0.1.15pypypiunverified

This library provides OpenTelemetry instrumentation for Google ADK (Agent Development Kit). It automatically patches Google ADK's runner, agent, LLM, and tool layers to generate spans that adhere to the OpenTelemetry GenAI semantic conventions, enabling detailed observability for Google ADK applications and LLM interactions. It is part of the broader OpenInference project by Arize-AI, which sees frequent updates and new instrumentation releases across various AI/ML frameworks. The current version is 0.1.10. [1, 2, 8, 10, 15]

pip install openinference-instrumentation-google-adk google-adk opentelemetry-sdk opentelemetry-exporter-otlp
INSTALL
IMPORT
SIG · OPENINFERENCE-INST
O
openinference-instrumentation-google-adk
observabilitypythonv0.1.15
Install
18.3s avg
Import
653ms
Disk
664MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.15 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.637s · 692.4MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 21.9s · import 0.669s · 665MB
664MB installed
● package 664MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GoogleADKInstrumentor
from openinference.instrumentation.google_adk import GoogleADKInstrumentor

This quickstart demonstrates how to set up OpenTelemetry tracing for a Google ADK agent using `openinference-instrumentation-google-adk`. It configures a `TracerProvider` (showing both console and OTLP export options), initializes the `GoogleADKInstrumentor`, and then runs a basic ADK agent that uses a tool. Ensure `GOOGLE_API_KEY` is set as an environment variable or directly in the code for Gemini access. [3, 6, 11, 12, 16, 17]

import os import asyncio from google.adk.agents import Agent from google.adk.runners import InMemoryRunner from google.genai import types from opentelemetry import trace from opentelemetry.sdk.resources import Resource from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import SimpleSpanProcessor, ConsoleSpanExporter from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter from openinference.instrumentation.google_adk import GoogleADKInstrumentor # Set your Google API Key (replace with your actual key or use env var) os.environ["GOOGLE_API_KEY"] = os.environ.get("GOOGLE_API_KEY", "YOUR_GEMINI_API_KEY_HERE") # 1. Configure OpenTelemetry Tracer Provider # For simplicity, using ConsoleSpanExporter here. In a real app, use OTLPSpanExporter # to send traces to an observability backend like Arize Phoenix, SigNoz, or Langfuse. resource = Resource.create({"service.name": "my-adk-agent"}) tracer_provider = TracerProvider(resource=resource) # To export to console (for quick verification): tracer_provider.add_span_processor(SimpleSpanProcessor(ConsoleSpanExporter())) # To export to an OTLP endpoint (e.g., a collector, Phoenix, SigNoz, Langfuse): # endpoint = os.environ.get("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT", "http://localhost:4317") # tracer_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(endpoint))) trace.set_tracer_provider(tracer_provider) # 2. Instrument Google ADK GoogleADKInstrumentor().instrument(tracer_provider=tracer_provider) # 3. Define a sample Google ADK Agent def get_current_time(city: str) -> dict: """Returns the current time for a specified city.""" # This is a dummy tool, replace with actual logic return {"status": "success", "time": f"The current time in {city} is 12:00 PM."} agent = Agent( name="TimeAgent", model="gemini-pro", # or "gemini-2.0-flash-exp" as per docs description="Agent to provide current time in a city.", instruction="You must use the get_current_time tool to find the answer.", tools=[get_current_time] ) async def main(): runner = InMemoryRunner(agent=agent) print("Agent started. Ask a question about time.") user_prompt = "What time is it in London?" print(f"User: {user_prompt}") response = await runner.run(types.Message(text=user_prompt)) print(f"Agent: {response.text}") user_prompt_2 = "What about New York?" print(f"User: {user_prompt_2}") response_2 = await runner.run(types.Message(text=user_prompt_2)) print(f"Agent: {response_2.text}") if __name__ == "__main__": asyncio.run(main())
Debug
Known issues
gotchaGoogle ADK itself may use 'Pre-GA' features. The instrumentation's behavior might be subject to change or have limited support when interacting with these features. Always refer to Google's official ADK documentation for stability status. [5]
fix
Stay updated with Google ADK and OpenInference releases. Consult the respective project documentation for any breaking changes related to Pre-GA features.
affects: <1.0.0
gotchaWhen deploying Google ADK agents to Vertex AI Agent Engine, the instrumentation must be configured within the remote agent module, not in the main application code. Additionally, it might be necessary to set `set_global_tracer_provider=False` when registering the tracer to avoid conflicts with the Agent Engine's own global provider. [11, 17]
fix
Ensure instrumentation setup (e.g., `GoogleADKInstrumentor().instrument(...)`) is inside the agent module. If conflicts arise, pass `set_global_tracer_provider=False` to your OpenTelemetry provider registration function.
affects: All versions when deploying to Vertex AI Agent Engine
gotchaThe instrumentation relies on the `GOOGLE_API_KEY` environment variable being correctly set for authentication with Gemini models via Google ADK. Failure to set this will prevent the underlying ADK agent from functioning and thus no traces will be generated. [3, 6, 11, 16, 17]
fix
Set `GOOGLE_API_KEY` in your environment (e.g., `export GOOGLE_API_KEY="your_key_here"`) or pass it directly in your application's configuration where `google-adk` is initialized.
affects: All versions
Upgrade
Version history
0.1.15latest on PyPI · released May 22, 2026
Audit
Dependencies
google-adkrequiredRequired for the instrumentation to function, as it instruments components of the Google Agent Development Kit.
openinference-instrumentationrequiredCore OpenInference utilities and base classes.
openinference-semantic-conventionsrequiredDefines the semantic conventions for OpenInference traces.
opentelemetry-apirequiredOpenTelemetry API for Python.
opentelemetry-instrumentationrequiredOpenTelemetry base instrumentation classes.
opentelemetry-sdkrequiredOpenTelemetry SDK for Python, essential for configuring TracerProviders and SpanProcessors.
opentelemetry-exporter-otlprequiredRequired to export OpenTelemetry traces to a collector.
opentelemetry-semantic-conventionsrequiredOpenTelemetry semantic conventions.
typing-extensionsrequiredProvides backports of features from future Python versions for type hints.
wraptrequiredA utility library for writing robust decorators and object proxies.
Agent activity
27 hits · last 30 days
node
20
OpenAI (training)
3
Resources
openinference-instrumentation-google-adk — pip install openinference-instrumentation-google-adk · libregistry