GoogleADKInstrumentor, which patches ADK components to emit OpenTelemetry spans.
Prerequisites
-
Install LangWatch SDK:
-
Install Google ADK and OpenInference instrumentor:
-
Set up Google Cloud authentication:
You’ll need to authenticate with Google Cloud. You can either:
- Set the
GOOGLE_API_KEYenvironment variable for Gemini API access - Use Application Default Credentials (ADC) if running on Google Cloud
- Use service account keys for production deployments
- Set the
Instrumentation with OpenInference
The OpenInference Google ADK instrumentor captures traces from your ADK agents and sends them to LangWatch.Basic Setup (Automatic Tracing)
Here’s the simplest way to instrument your application:Set
LANGWATCH_API_KEY in the environment before you run this. Without it the
SDK sends nothing.Optional: Add metadata with a decorator
To attach metadata to the trace, wrap the call in@langwatch.trace() and run
the agent with Runner.run_async:
How it Works
-
langwatch.setup(): Initializes the LangWatch SDK, which includes setting up an OpenTelemetry trace exporter. This exporter is ready to receive spans from any OpenTelemetry-instrumented library in your application. -
GoogleADKInstrumentor(): The OpenInference instrumentor automatically patches Google ADK components to create OpenTelemetry spans for their operations, including:- Agent initialization
- Tool calls
- Model completions
- Session management
-
Optional Decorators: You can optionally use
@langwatch.trace()to add additional context and metadata to your traces, but it’s not required for basic functionality. The decorator parents the agent spans only overRunner.run_async.
Notes
- You do not need to set any OpenTelemetry environment variables or configure exporters manually.
langwatch.setup()handles it. - You can combine Google ADK instrumentation with other instrumentors (e.g., OpenAI, LangChain) by adding them to the
instrumentorslist. - The
@langwatch.trace()decorator is optional - the OpenInference instrumentor will capture all ADK activity automatically. Use it withRunner.run_async, never with the synchronousRunner.run. - For advanced configuration (custom attributes, endpoint, etc.), see the Python integration guide.
Troubleshooting
- Make sure your
LANGWATCH_API_KEYis set in the environment. - If you see no traces in LangWatch, check that the instrumentor is included in
langwatch.setup()and that your agent code is being executed. - Ensure you have the correct Google API key set for Gemini access.
AttributeError: module 'google.adk.flows.llm_flows.functions' has no attribute 'trace_tool_call'onlangwatch.setup(): youropeninference-instrumentation-google-adkis too old for your Google ADK version. ADK 1.32 removed that symbol; the fix shipped in instrumentor 0.1.11. Runpip install -U "openinference-instrumentation-google-adk>=0.1.11". If it still fails, confirm the upgrade actually applied in the running interpreter withpip show openinference-instrumentation-google-adk.- One agent run shows up as two traces, one of them empty except for your decorator span: you wrapped the synchronous
Runner.run. Switch toRunner.run_async, or drop the decorator. See the warning above. - The metadata you set with
trace.update()is on a trace with no agent spans: same cause, same fix.