Skip to main content

Helper package for OTEL setup to send traces to Arize & Phoenix

Project description

arize banner



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 the traces to Arize, Phoenix, or custom collectors.

Installation

Install arize-otel using 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 instrument() after using register_otel:

# Setup OTEL via our convenience function
register_otel(
    # See details in examples below...
)

# Instrument your application using OpenInference AutoInstrumentators
from openinference.instrumentation.openai import OpenAIInstrumentor
OpenAIInstrumentor().instrument()

The above code snippet will yield a fully setup and instrumented application. It is worth noting that this is completely optional. The usage of this package is for convenience only, you can set up OpenTelemetry and send traces to Arize and Phoenix without installing this or any other package from Arize.

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.

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 up 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

arize_otel-0.1.1.tar.gz (7.7 kB view hashes)

Uploaded Source

Built Distribution

arize_otel-0.1.1-py3-none-any.whl (8.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page