Registry /
observability / openinference-instrumentation-google-adk
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
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.637s · 692.4MB
glibcpy 3.10–3.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]fixStay 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]fixEnsure 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]fixSet `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.