Arize-OTel
Arize-OTel is a helper package designed to streamline OpenTelemetry (OTel) setup for sending traces to Arize AI and Arize Phoenix. It simplifies instrumenting Python applications by providing pre-configured exporters and an instrumentor for common libraries, enabling quick observability integration. The current version is 0.12.0, and the project maintains a regular release cadence for new features, bug fixes, and dependency updates.
Common errors
-
ImportError: cannot import name 'configure_opentelemetry_for_arize' from 'arize_otel.tracing.config'
cause The function `configure_opentelemetry_for_arize` was renamed to `configure_opentelemetry_for_arize_phoenix` in version 0.10.0.fixUpdate your import and function call to `from arize_otel.tracing.config import configure_opentelemetry_for_arize_phoenix`. -
ModuleNotFoundError: No module named 'arize_phoenix.data' (or 'arize_phoenix.evals')
cause The core `arize-otel` installation does not include all optional dependencies for `arize-phoenix`'s data and evals components.fixInstall `arize-otel` with the necessary extras: `pip install "arize-otel[data,evals]"`. -
My Flask/Requests/Django application is not being automatically traced, even with ArizeInstrumentor().instrument() called.
cause Automatic instrumentation relies on specific `opentelemetry-instrumentation-*` packages for each library. These must be installed separately.fixEnsure you have installed the relevant instrumentation package (e.g., `pip install opentelemetry-instrumentation-requests` for `requests`) in addition to `arize-otel`.
Warnings
- breaking The primary configuration function `configure_opentelemetry_for_arize` was renamed to `configure_opentelemetry_for_arize_phoenix` in `arize-otel` version 0.10.0.
- gotcha To utilize all features of Arize Phoenix (e.g., data visualization, evaluations), you must install `arize-otel` with the `data` and `evals` extras.
- gotcha Automatic instrumentation of third-party libraries (like `requests`, `flask`, `django`, `fastapi`) requires their respective `opentelemetry-instrumentation-*` packages to be installed alongside `arize-otel` and `ArizeInstrumentor().instrument()` to be called.
- gotcha Arize API and Space Keys (`ARIZE_API_KEY`, `ARIZE_SPACE_KEY`) are crucial for sending traces to Arize. Ensure these are provided either via environment variables or explicitly passed to `configure_opentelemetry_for_arize_phoenix`.
Install
-
pip install arize-otel -
pip install "arize-otel[data,evals]"
Imports
- configure_opentelemetry_for_arize_phoenix
from arize_otel.tracing.config import configure_opentelemetry_for_arize
from arize_otel.tracing.config import configure_opentelemetry_for_arize_phoenix
- ArizeInstrumentor
from arize_otel.tracing.instrumentation import ArizeInstrumentor
Quickstart
import os
from opentelemetry import trace
from arize_otel.tracing.config import configure_opentelemetry_for_arize_phoenix
from arize_otel.tracing.instrumentation import ArizeInstrumentor
# Configure OpenTelemetry to send traces to Arize and Phoenix
# Ensure ARIZE_API_KEY and ARIZE_SPACE_KEY environment variables are set.
configure_opentelemetry_for_arize_phoenix(
arize_api_key=os.environ.get("ARIZE_API_KEY", ""),
arize_space_key=os.environ.get("ARIZE_SPACE_KEY", ""),
phoenix_host="http://localhost:6006" # Optional: defaults to "http://localhost:6006"
)
# Manually instrument an application using OpenTelemetry Tracer
tracer = trace.get_tracer("my-arize-app")
with tracer.start_as_current_span("my-manual-span"):
print("Performing some traced operation...")
# Automatically instrument common libraries (e.g., requests, flask, django)
# Ensure you have installed the respective opentelemetry-instrumentation- packages.
ArizeInstrumentor().instrument()
# Example using a common library (e.g., requests) which will be automatically traced
try:
import requests
response = requests.get("https://www.example.com")
print(f"Requests response status: {response.status_code}")
except ImportError:
print("Install 'opentelemetry-instrumentation-requests' to trace requests.")
print("Tracing configured and example operation completed.")