Skip to main content
PyPI Version Provides a lightweight wrapper around OpenTelemetry primitives with Phoenix-aware defaults. Also includes tracing decorators for common GenAI patterns.

Installation

Starting in 0.16.0, phoenix.otel re-exports the OpenInference context managers and semantic conventions, so manual instrumentation no longer requires separately installing openinference-instrumentation or openinference-semantic-conventions. On older versions, import them from openinference.instrumentation and openinference.semconv.trace instead.
arize-phoenix-otel is versioned independently of the Phoenix server; the two are not coupled. Any recent SDK version works with any Phoenix server version — there is no version pairing to track. See Version compatibility.

Quick Start

That’s it! By default, register reads the PHOENIX_COLLECTOR_ENDPOINT environment variable. If the variable is not set, register uses http://localhost:6006 and exports over gRPC to localhost:4317.

Configuration

Environment Variables

The SDK automatically reads these environment variables:
register() also auto-loads PHOENIX_-prefixed settings from a .env.phoenix file discovered by walking up from the current directory (process environment variables take precedence). Set PHOENIX_DISCOVER_CONFIG=false to opt out. See Environment Variables.

Endpoint Configuration

You can also configure the endpoint directly in code:
register uses the endpoint argument as given. For HTTP, include the /v1/traces path. For gRPC, include the port, which is 4317 by default.

Protocol selection

register, TracerProvider, SimpleSpanProcessor, and BatchSpanProcessor pick the OTLP transport once, from the endpoint as written. The first rule that matches applies:
  1. If you pass protocol, the SDK uses it.
  2. A Phoenix Cloud URL uses HTTP.
  3. A URL with a path, such as /v1/traces or /phoenix, uses HTTP. From PHOENIX_COLLECTOR_ENDPOINT, the SDK keeps the path and appends /v1/traces if it is missing. The SDK uses an endpoint argument as given.
  4. A URL with no path (scheme://host[:port]) uses gRPC. From PHOENIX_COLLECTOR_ENDPOINT, the SDK sends to the same host on PHOENIX_GRPC_PORT (default 4317). The SDK uses an endpoint argument as host:port, as given.
If the gRPC port is not reachable, for example behind a reverse proxy, an ingress, or a managed host, pass protocol="http/protobuf".

Register Options


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).

Manual Instrumentation Helpers

phoenix.otel re-exports the OpenInference context managers and semantic conventions so you can add session, user, metadata, tag, prompt template, and suppression context — plus set OpenInference span attributes — from a single import:
Requires arize-phoenix-otel>=0.16.0. Lower-level helpers (get_llm_attributes, TraceConfig, Message, Image, …) continue to live in the openinference-instrumentation package.
See Using Tracing Helpers for a full walkthrough of manual instrumentation.

Advanced: OTel Primitives

For granular control, use Phoenix wrappers as drop-in replacements for OpenTelemetry primitives:
These wrappers accept an endpoint argument to automatically infer the appropriate SpanExporter.
Using environment variables:
Custom resources:
Batch processing:
Custom gRPC endpoint:

Advanced: TracerProvider Options

Both register() 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