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 ID and API Key. 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_id = "your-arize-space-id",
    api_key = "your-arize-api-key",
    model_id = "your-model-id",
    model_version = "your-model-version", # OPTIONAL
)

Send traces to Local 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 local Phoenix endpoint, but you can specify your own (explained in an example below). 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.

Send traces via HTTP:

register_otel(
    endpoints = Endpoints.LOCAL_PHOENIX_HTTP,
    project_name = "your-project-name", # OPTIONAL
)

Send traces via gRPC:

register_otel(
    endpoints = Endpoints.LOCAL_PHOENIX_GRPC,
    project_name = "your-project-name", # OPTIONAL
)

Send traces to Hosted Phoenix

To send traces to your Hosted Phoenix, also known as Llamatrace, you just need to provide the correct endpoint. In the example below we have specified said endpoint, as well as the Phoenix API key required. Optionally, you can specify a project to which to send the traces, exactly as above with a local Phoenix instance.

register_otel(
    endpoints = Endpoints.HOSTED_PHOENIX,
    api_key = "your-hosted-phoenix-api-key",
    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_id = "your-space-id",
    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
)

Turn off batch processing of spans

We default to using BatchSpanProcessor from OpenTelemetry because it is non-blocking in case telemetry goes down. In contrast, "SimpleSpanProcessor processes spans as they are created." This can be helpful in development. You can use SimpleSpanProcessor with the option use_batch_processor=False.

register_otel(
    # other options...
    use_batch_processor=False
)

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.5.3.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

arize_otel-0.5.3-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file arize_otel-0.5.3.tar.gz.

File metadata

  • Download URL: arize_otel-0.5.3.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for arize_otel-0.5.3.tar.gz
Algorithm Hash digest
SHA256 1bc110fb774bae27ae515495bee9362a8f6543c5edaf0aa1fda76e972c4a20cd
MD5 8d47222df2aa5e744fc4b896b6f89c13
BLAKE2b-256 8f67e5c6ad8bc870a4668ad254506d0e4398807cc9d7fd916e69c51bbf719ce4

See more details on using hashes here.

Provenance

The following attestation bundles were made for arize_otel-0.5.3.tar.gz:

Publisher: release-sdks.yml on Arize-ai/arize

Attestations:

File details

Details for the file arize_otel-0.5.3-py3-none-any.whl.

File metadata

  • Download URL: arize_otel-0.5.3-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for arize_otel-0.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9904831617bb601b4e5d952d4a763874990c621f08938739c959921445519e44
MD5 e1b86853b57a3e946612fb70c4c4f35c
BLAKE2b-256 1e492461cdc57ef554c16d780c81b1e78f2e91dfa9ae0e9d3b6f1afb8010d432

See more details on using hashes here.

Provenance

The following attestation bundles were made for arize_otel-0.5.3-py3-none-any.whl:

Publisher: release-sdks.yml on Arize-ai/arize

Attestations:

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