Instrument Google ADK for Java with OpenInference and export traces to Phoenix.
Google ADK creates OpenTelemetry spans. The OpenInference Java agent enriches those spans and sends them to Phoenix without changes to your agent code.
No uv? pip install arize-phoenix && phoenix serve does the same thing. See Terminal setup for customization.
docker run -p 6006:6006 -p 4317:4317 arizephoenix/phoenix:latest
Images are published to Docker Hub. See Docker for volumes, PostgreSQL, and other options.
Run Phoenix on your own infrastructure, backed by PostgreSQL so traces persist beyond a single process. This is the option to reach for once Phoenix is shared across a team or environment.The self-hosting guide covers Kubernetes, Helm, Railway, AWS CloudFormation, Google Cloud Run, Azure, and Render, plus authentication and configuration.
Phoenix serves its UI and OTLP HTTP on port 6006, and OTLP gRPC on port 4317. For a local instance that’s http://localhost:6006 — leave it running while you work.
The Phoenix example includes the ADK agent, OpenTelemetry configuration, and Gradle launch task. Set the path to your shaded OpenInference agent JAR, then run it:
export GOOGLE_API_KEY="your-key"export OPENINFERENCE_ADK_AGENT_JAR="/path/to/adk-agent.jar"cd java/examples/google-adkgradle -PagentJar="$OPENINFERENCE_ADK_AGENT_JAR" run
Open Phoenix and select the google-adk-java project.
Register a global OpenTelemetry SDK with an OTLP exporter and the openinference.project.name resource attribute. Do this before constructing any ADK object because ADK captures the global OpenTelemetry instance when its telemetry class loads. The following is taken from the example’s WeatherAgent.java:
Resource resource = Resource.getDefault().merge(Resource.create(Attributes.of( AttributeKey.stringKey("openinference.project.name"), "google-adk-java")));OtlpGrpcSpanExporter exporter = OtlpGrpcSpanExporter.builder() .setEndpoint(System.getenv().getOrDefault( "OTEL_EXPORTER_OTLP_ENDPOINT", "http://localhost:4317")) .build();SdkTracerProvider tracerProvider = SdkTracerProvider.builder() .setResource(resource) .addSpanProcessor(BatchSpanProcessor.builder(exporter).build()) .build();OpenTelemetrySdk.builder() .setTracerProvider(tracerProvider) .buildAndRegisterGlobal();// Construct and run ADK objects after registration.
Launch your application with the shaded agent JAR: