Helper package for OTEL setup to send traces to Arize & Phoenix
Project description
Overview
The arize-otel
package is meant to be a very lightweight convenience package to help set up OpenTelemetry for tracing LLM applications
and send them to Arize, Phoenix, or custom collectors.
Installation
Install arize-otel
via pip
pip install arize-otel
Quickstart
You only need one import to use this package:
from arize_otel import register_otel, Endpoints
The following examples showcase how to use register_otel
to setup Opentelemetry in order to send traces to a collector. However,
this is NOT the same as instrumenting
your application. For instance, you can use any of our OpenInference AutoInstrumentators.
Assuming we use the OpenAI autoinstrumentation, we need to run the following command after any of the examples below:
from openinference.instrumentation.openai import OpenAIInstrumentor
register_otel(
# See details in examples below...
)
OpenAIInstrumentor().instrument()
The above code snippet will yield a fully setup and instrumented application. In the following sections we have examples on how to use
the register_otel
function:
Send traces to Arize
To send traces to Arize you need to authenticate via the space and API keys. You can find them in the Space Settings page in the Arize platform. In addition, you'll need to specify the model ID, an unique name to identify your model in the Arize platform. Optionally, you can set the model version, which serves to to group a subset of data, given the same model ID, to compare and track changes.
register_otel(
endpoints = Endpoints.ARIZE,
space_key = "your-space-key",
api_key = "your-api-key",
model_id = "your-model-id",
model_version = "your-model-version", # OPTIONAL
)
Send traces to Phoenix
To send traces to your local Phoenix server you just need to provide the correct endpoint. In the example below we have specified the default Phoenix endpoint, but you can specify your own (see next example). Optionally, you can specify a project to send the traces to. A project is a collection of traces that are related to a single application or service. You can have multiple projects, each with multiple traces.
register_otel(
endpoints = Endpoints.PHOENIX_LOCAL,
project_name = "your-project-name", # OPTIONAL
)
Send traces to Custom Endpoint
Sending traces to a collector on a custom endpoint is simple, you just need to provide the endpoint. If this endpoint corresponds to an Arize or Phoenix deployment, you can add any of the options described in the examples above. or a Phoenix
register_otel(
endpoints = "https://my-custom-endpoint"
# any other options...
)
Send traces to Multiple Endpoints
In this example we send traces to the default Arize and Phoenix endpoints, as well as to a third custom one. We also set all the options mentioned until now.
register_otel(
endpoints = [
Endpoints.ARIZE,
Endpoints.PHOENIX_LOCAL,
"https://my-custom-endpoint",
]
space_key = "your-space-key",
api_key = "your-api-key",
model_id = "your-model-id",
model_version = "your-model-version", # OPTIONAL
project_name = "your-project-name", # OPTIONAL
)
Debug
As you're setting your tracing, it is helpful to print to console the spans created. You can achieve this by setting log_to_console=True
.
register_otel(
# other options...
log_to_console=True
)
Questions?
Find us in our Slack Community or email support@arize.com
Copyright, Patent, and License
Copyright 2024 Arize AI, Inc. All Rights Reserved.
This software is licensed under the terms of the 3-Clause BSD License. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for arize_otel-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f84e0010638c6e4dcc41fe19c051f7451e3bf902325569795001713fea47d4e |
|
MD5 | 069103d93ac975d5e1bac31530d6610b |
|
BLAKE2b-256 | 61faa148fe0718e625133f8026f130acede0c23c34f7d4e2f5a7702e444eb006 |