Send Traces from Phoenix -> Arize

You can use Phoenix to collect traces, run evals, and perform data modifications in a notebook environment until you're ready to export data to Arize using our Python SDK.

Here's how you do it:

Collect Traces in Phoenix

Enable Phoenix tracing is very similar to what we showed in the section above since it also leverages the OpenInference instrumentation. For more details, see the Phoenix Quickstart Guide to Tracing.

Your application traces should stream into the Phoenix UI as shown below

Query for specific traces

When you're ready to send your data to Arize, run the following command to export your traces from Phoenix.

spans_df = px.Client().get_spans_dataframe()

This command creates a dataframe object as shown below:

If you want to get the evaluations as well attached to the spaces, run the commands below.

trace_dataset = px.Client().get_trace_dataset()
evals_df = tds.get_evals_dataframe()

Send data to Arize

The dataframe can be directly sent to Arize using our Python SDK. Schema mapping is not required for OpenInference traces since Arize will automatically understand the column names from your dataframe.

To send tracing data via the Python SDK, it must be installed with extra dependencies

pip install arize[Tracing]

(Cloud import support coming soon)

The following code example shows how to send a dataframe with traces exported from Phoenix to Arize via the log_spans method. Note that we do not need to specify any Schema.

from arize.pandas.logger import Client

SPACE_KEY = "SPACE_KEY"
API_KEY = "API_KEY"

if SPACE_KEY == "SPACE_KEY" or API_KEY == "API_KEY":
    raise ValueError("❌ NEED TO CHANGE SPACE AND/OR API_KEY")
else:
    print("✅ Import and Setup Arize Client Done! Now we can start using Arize!")
    
arize_client = Client(space_key=SPACE_KEY, api_key=API_KEY)
model_id = "generative-spans-tutorial-test" # the model name in Arize
model_version = "1.0" # (optional) the model version

response = arize_client.log_spans(
    dataframe=spans_df,
    evals_dataframe=evals_df, # if you do not have any evals, remove this line
    model_id=model_id,
    model_version=model_version, # optional
)

# If successful, the server will return a status_code of 200
if response.status_code != 200:
    print(f"❌ logging failed with response code {response.status_code}, {response.text}")
else:
    print(f"✅ You have successfully logged training set to Arize")

For more in-detail demonstration, check our Colab tutorial:

Last updated

Copyright © 2023 Arize AI, Inc