arize-phoenix-otel package provides OpenTelemetry-based instrumentation for automatic tracing of LLM applications.
Installation
Quick Start
register()
The main function for setting up Phoenix tracing.Signature
Parameters
The collector endpoint to which spans will be exported. If not provided, the
PHOENIX_COLLECTOR_ENDPOINT environment variable will be used. The export protocol will be inferred from the endpoint.Default: http://localhost:6006The name of the project to which spans will be associated. If not provided, the
PHOENIX_PROJECT_NAME environment variable will be used.Default: defaultIf
True, spans will be processed using a BatchSpanProcessor. If False, spans will be processed one at a time using a SimpleSpanProcessor.Recommended: Use True for production environments.Default: FalseIf
False, the TracerProvider will not be set as the global tracer provider.Default: TrueOptional headers to include in the request to the collector. If not provided, the
PHOENIX_CLIENT_HEADERS environment variable will be used.The protocol to use for the collector endpoint. If not provided, the protocol will be inferred from the endpoint URL.
If
True, configuration details will be printed to stdout.Default: TrueIf
True, automatically instruments all installed OpenInference libraries (OpenAI, LangChain, LlamaIndex, etc.).Default: FalseAPI key for authentication. If not provided, the
PHOENIX_API_KEY environment variable will be used.Returns
An OpenTelemetry TracerProvider configured for Phoenix.
Examples
Advanced Components
For fine-grained control, you can use the lower-level components directly.TracerProvider
An extension ofopentelemetry.sdk.trace.TracerProvider with Phoenix-aware defaults.
SpanProcessors
SimpleSpanProcessor
Processes and exports spans immediately (good for development).BatchSpanProcessor
Batches spans for efficient export (recommended for production).SpanExporters
HTTPSpanExporter
Exports spans via HTTP/protobuf.GRPCSpanExporter
Exports spans via gRPC.Manual Instrumentation
If you don’t useauto_instrument=True, you can manually instrument specific libraries:
Resource Attributes
Set custom resource attributes:Environment Variables
Phoenix server URL (default:
http://localhost:6006)API key for authentication with Phoenix Cloud
Default project name for traces (default:
default)Additional headers to send with requests (comma-separated
key:value pairs)Standard OpenTelemetry headers (comma-separated
key=value pairs)Configuration Examples
Development Setup
Production Setup
Multi-Project Setup
Troubleshooting
Traces Not Appearing
- Check that Phoenix is running:
http://localhost:6006 - Verify the endpoint URL is correct
- Enable verbose mode:
register(verbose=True) - Check for errors in the console output
Performance Issues
- Use
batch=Truefor production - Adjust batch processor settings:
Authentication Errors
- Verify API key is correct
- Check headers are properly formatted
- Ensure authorization header uses “Bearer” prefix
See Also
- Python Client Reference - Interact with Phoenix
- Python Evals Reference - Run evaluations
- Tracing Guide - Learn about tracing concepts