Installation
Quick Start
register reads the PHOENIX_COLLECTOR_ENDPOINT environment variable, falling back to http://localhost:4317 using gRPC if the variable is not set.
Configuration
Environment Variables
The SDK automatically reads these environment variables:| Variable | Description |
|---|---|
PHOENIX_COLLECTOR_ENDPOINT | Phoenix server URL |
PHOENIX_PROJECT_NAME | Project name for traces |
PHOENIX_API_KEY | API key (automatically adds auth header) |
PHOENIX_CLIENT_HEADERS | Custom headers for requests |
PHOENIX_GRPC_PORT | Override default gRPC port |
Endpoint Configuration
You can also configure the endpoint directly in code:When using the
endpoint argument, you must specify the fully qualified URL. HTTP uses /v1/traces, while gRPC uses port 4317 by default.Register Options
| Parameter | Description |
|---|---|
project_name | Phoenix project name (or PHOENIX_PROJECT_NAME env var) |
endpoint | Collector endpoint URL |
protocol | Transport protocol: "grpc" or "http/protobuf" |
headers | Custom headers for requests |
batch | Process spans in batch (default: False) |
auto_instrument | Auto-instrument supported libraries |
Spans may not be exported if still queued in the processor when your process exits. With
batch=True, call tracer_provider.shutdown() to explicitly flush before exit. Alternatively, use batch=False for immediate export or a context manager (with register(...) as tracer_provider).Advanced: OTel Primitives
For granular control, use Phoenix wrappers as drop-in replacements for OpenTelemetry primitives:endpoint argument to automatically infer the appropriate SpanExporter.
More examples
More examples
Using environment variables:Custom resources:Batch processing:Custom gRPC endpoint:
Advanced: TracerProvider Options
Bothregister() and TracerProvider accept standard OpenTelemetry TracerProvider kwargs for advanced features like custom ID generators and sampling:
Reference Documentation
Full API Reference
Complete API documentation for tracing setup, decorators, and OpenTelemetry configuration

