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.
If your Phoenix instance isn’t running on localhost, adjust the endpoint in the code below as needed. If it has authentication enabled, also set PHOENIX_API_KEY to an API key from its Settings page.
Configuration for Phoenix Tracing
import io.opentelemetry.api.common.AttributeKey;import io.opentelemetry.api.common.Attributes;import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator;import io.opentelemetry.context.propagation.ContextPropagators;import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder;import io.opentelemetry.sdk.OpenTelemetrySdk;import io.opentelemetry.sdk.resources.Resource;import io.opentelemetry.sdk.trace.SdkTracerProvider;import io.opentelemetry.sdk.trace.export.BatchSpanProcessor;import java.time.Duration;import java.util.concurrent.TimeUnit;private static SdkTracerProvider tracerProvider;private static void initializeOpenTelemetry() { // Create resource with service name Resource resource = Resource.getDefault() .merge(Resource.create(Attributes.of( AttributeKey.stringKey("service.name"), "langchain4j", AttributeKey.stringKey("openinference.project.name"), System.getenv().getOrDefault("PHOENIX_PROJECT_NAME", "langchain4j-project"), AttributeKey.stringKey("service.version"), "0.1.0"))); String apiKey = System.getenv("PHOENIX_API_KEY"); OtlpGrpcSpanExporterBuilder otlpExporterBuilder = OtlpGrpcSpanExporter.builder() .setEndpoint("http://localhost:4317"); if (apiKey != null && !apiKey.isEmpty()) { otlpExporterBuilder.addHeader("Authorization", "Bearer " + apiKey); } OtlpGrpcSpanExporter otlpExporter = otlpExporterBuilder.build(); // Create a tracer provider with the OTLP exporter for Phoenix. tracerProvider = SdkTracerProvider.builder() .addSpanProcessor(BatchSpanProcessor.builder(otlpExporter) .setScheduleDelay(Duration.ofSeconds(1)) .build()) .setResource(resource) .build(); // Build OpenTelemetry SDK OpenTelemetrySdk.builder() .setTracerProvider(tracerProvider) .setPropagators(ContextPropagators.create(W3CTraceContextPropagator.getInstance())) .buildAndRegisterGlobal(); System.out.println("OpenTelemetry initialized. Traces will be sent to Phoenix at http://localhost:6006"); }
Run LangChain4j
Attach the OpenInference model listener to the LangChain4j chat model so requests and responses produce OpenInference LLM spans.
import com.arize.instrumentation.langchain4j.LangChain4jInstrumentor;import dev.langchain4j.model.openai.OpenAiChatModel;import java.util.List;initializeOpenTelemetry();// Create the OpenInference listener for LangChain4j model events.LangChain4jInstrumentor instrumentor = LangChain4jInstrumentor.instrument();// Use LangChain4j as normal; the listener emits an OpenInference LLM span.OpenAiChatModel model = OpenAiChatModel.builder() .apiKey(System.getenv("OPENAI_API_KEY")) .modelName("gpt-4o-mini") .listeners(List.of(instrumentor.createModelListener())) .build();String response = model.chat("What is the capital of France?");System.out.println(response);tracerProvider.forceFlush().join(10, TimeUnit.SECONDS);tracerProvider.shutdown().join(10, TimeUnit.SECONDS);
Observe
Once configured, your traces will be automatically sent to Phoenix where you can:
Monitor Performance: Track latency, throughput, and error rates
Analyze Usage: View token usage, model performance, and cost metrics
Debug Issues: Trace request flows and identify bottlenecks
Evaluate Quality: Run evaluations on your LLM outputs