Skip to content

Commit

Permalink
chore: sync docs to main (#4418)
Browse files Browse the repository at this point in the history
* docs: Add haystack note on using pipelines (GITBOOK-820)

* docs: Adding videos to relevant pages (GITBOOK-819)

* docs: Jeffrey's Aug 21 changes - Update section 2 to reflect time range (GITBOOK-822)

* docs: Anthropic Instrumentation - Phoenix (GITBOOK-824)

* docs: Anthropic tweaks - Phoenix (GITBOOK-825)

* docs: Fix Anthropic page - Phoenix (GITBOOK-826)

* docs: phoenix.otel quickstart changes (GITBOOK-828)

* docs: phoenix.otel guide (GITBOOK-829)

* docs: Beef up Tracing Overview page and refresh links (John reviewed) (GITBOOK-830)

* docs: re-name headers (GITBOOK-831)

* docs: No subject (GITBOOK-832)

* docs: Make integrations a Grid (GITBOOK-833)

* docs: vercel (GITBOOK-834)

* docs: Send Traces from Phoenix to Arize (GITBOOK-835)

* docs: Keep Send traces to Arize in Arize docs (GITBOOK-836)

---------

Co-authored-by: John Gilhuly <jgilhuly@arize.com>
Co-authored-by: David Burch <davidburch@arize.com>
Co-authored-by: Jeffrey Peng <jpeng@arize.com>
Co-authored-by: Parth Shisode <pshisode@arize.com>
Co-authored-by: Dustin Ngo <dngo@arize.com>
Co-authored-by: Dat Ngo <dat@arize.com>
Co-authored-by: Eric Xiao <exiao@arize.com>
  • Loading branch information
8 people authored Aug 28, 2024
1 parent 63d0adb commit 7faaba2
Show file tree
Hide file tree
Showing 23 changed files with 436 additions and 71 deletions.
Binary file not shown.
Binary file added docs/.gitbook/assets/phoenix-traces.webp
Binary file not shown.
Binary file added docs/.gitbook/assets/send-traces.webp
Binary file not shown.
7 changes: 7 additions & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* [LlamaIndex](tracing/integrations-tracing/llamaindex.md)
* [LangChain](tracing/integrations-tracing/langchain.md)
* [Haystack](tracing/integrations-tracing/haystack.md)
* [Anthropic](tracing/integrations-tracing/anthropic.md)
* [Groq](tracing/integrations-tracing/groq.md)
* [DSPy](tracing/integrations-tracing/dspy.md)
* [VertexAI](tracing/integrations-tracing/vertexai.md)
Expand All @@ -36,11 +37,16 @@
* [Instructor](tracing/integrations-tracing/instructor.md)
* [OpenAI Node SDK](tracing/integrations-tracing/openai-node-sdk.md)
* [LangChain.js](tracing/integrations-tracing/langchain.js.md)
* [Vercel AI SDK](tracing/integrations-tracing/vercel-ai-sdk.md)
* [Concepts: Tracing](tracing/concepts-tracing.md)
* [Traces](tracing/concepts-tracing/what-are-traces.md)
* [How Tracing Works](tracing/concepts-tracing/how-does-tracing-work.md)
* [Annotating Traces](tracing/concepts-tracing/how-to-annotate-traces.md)
* [How-to: Tracing](tracing/how-to-tracing/README.md)
* [Setup Tracing](tracing/how-to-tracing/setup-tracing/README.md)
* [Setup Tracing: Python](tracing/how-to-tracing/setup-tracing/setup-tracing-python/README.md)
* [Using OTEL Python Directly](tracing/how-to-tracing/setup-tracing/setup-tracing-python/using-otel-python-directly.md)
* [Setup Tracing: TS](tracing/how-to-tracing/setup-tracing/setup-tracing-ts.md)
* [Tracing Core Concepts](tracing/how-to-tracing/tracing-core-concepts.md)
* [Customize Traces](tracing/how-to-tracing/customize-traces.md)
* [Customize Spans](tracing/how-to-tracing/customize-spans/README.md)
Expand All @@ -58,6 +64,7 @@
* [Save and Load Traces](tracing/how-to-tracing/save-and-load-traces.md)
* [Capture Feedback](tracing/how-to-tracing/capture-feedback.md)
* [Trace a Deployed App](tracing/how-to-tracing/trace-a-deployed-app.md)
* [Configure Tracing](tracing/how-to-tracing/configure-tracing.md)
* [Use Cases: Tracing](tracing/use-cases-tracing/README.md)
* [Evaluate RAG](use-cases/rag-evaluation.md)
* [Structured Data Extraction](tracing/use-cases-tracing/structured-extraction.md)
Expand Down
30 changes: 17 additions & 13 deletions docs/concepts/llm-traces.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ description: Tracing the execution of LLM applications using Telemetry

# Overview: Tracing

Tracing is a powerful tool for understanding how your LLM application works. Phoenix has best-class tracing capabilities and is not tied to any LLM vendor or framework. Phoenix accepts traces over the OpenTelemetry protocol (OTLP) and supports first-class instrumentation for a variety of frameworks ( [LlamaIndex](../tracing/integrations-tracing/llamaindex.md), [LangChain](../tracing/integrations-tracing/langchain.md),[ DSPy](../tracing/integrations-tracing/dspy.md)), SDKs ([OpenAI](../tracing/integrations-tracing/openai.md), [Bedrock](../tracing/integrations-tracing/bedrock.md), [Mistral](../tracing/integrations-tracing/mistralai.md), [Vertex](../tracing/integrations-tracing/vertexai.md)), and Languages. (Python, Javascript, etc.)

Tracing can help you track down issues like:

* **Application latency** - highlighting slow invocations of LLMs, Retrievers, etc.
* **Token Usage** - Displays the breakdown of token usage with LLMs to surface up your most expensive LLM calls
* **Runtime Exceptions** - Critical runtime exceptions such as rate-limiting are captured as exception events.
* **Retrieved Documents** - view all the documents retrieved during a retriever call and the score and order in which they were returned
* **Embeddings** - view the embedding text used for retrieval and the underlying embedding model
* **LLM Parameters** - view the parameters used when calling out to an LLM to debug things like temperature and the system prompts
* **Prompt Templates** - Figure out what prompt template is used during the prompting step and what variables were used.
* **Tool Descriptions -** view the description and function signature of the tools your LLM has been given access to
* **LLM Function Calls** - if using OpenAI or other a model with function calls, you can view the function selection and function messages in the input messages to the LLM.
LLM tracing records the paths taken by requests as they propagate through multiple steps or components of an LLM application. For example, when a user interacts with an LLM application, tracing can capture the sequence of operations, such as document retrieval, embedding generation, language model invocation, and response generation to provide a detailed timeline of the request's execution.

Tracing is a helpful tool for understanding how your LLM application works. Phoenix offers comprehensive tracing capabilities that are not tied to any specific LLM vendor or framework. Phoenix accepts traces over the OpenTelemetry protocol (OTLP) and supports first-class instrumentation for a variety of frameworks ( [LlamaIndex](../tracing/integrations-tracing/llamaindex.md), [LangChain](../tracing/integrations-tracing/langchain.md),[ DSPy](../tracing/integrations-tracing/dspy.md)), SDKs ([OpenAI](../tracing/integrations-tracing/openai.md), [Bedrock](../tracing/integrations-tracing/bedrock.md), [Mistral](../tracing/integrations-tracing/mistralai.md), [Vertex](../tracing/integrations-tracing/vertexai.md)), and Languages. (Python, Javascript, etc.)

Using Phoenix's tracing capabilities can provide important insights into the inner workings of your LLM application. By analyzing the collected trace data, you can identify and address various performance and operational issues and improve the overall reliability and efficiency of your system.

* **Application Latency**: Identify and address slow invocations of LLMs, Retrievers, and other components within your application, enabling you to optimize performance and responsiveness.
* **Token Usage**: Gain a detailed breakdown of token usage for your LLM calls, allowing you to identify and optimize the most expensive LLM invocations.
* **Runtime Exceptions**: Capture and inspect critical runtime exceptions, such as rate-limiting events, that can help you proactively address and mitigate potential issues.
* **Retrieved Documents**: Inspect the documents retrieved during a Retriever call, including the score and order in which they were returned to provide insight into the retrieval process.
* **Embeddings**: Examine the embedding text used for retrieval and the underlying embedding model to allow you to validate and refine your embedding strategies.
* **LLM Parameters**: Inspect the parameters used when calling an LLM, such as temperature and system prompts, to ensure optimal configuration and debugging.
* **Prompt Templates**: Understand the prompt templates used during the prompting step and the variables that were applied, allowing you to fine-tune and improve your prompting strategies.
* **Tool Descriptions**: View the descriptions and function signatures of the tools your LLM has been given access to in order to better understand and control your LLM’s capabilities.
* **LLM Function Calls**: For LLMs with function call capabilities (e.g., OpenAI), you can inspect the function selection and function messages in the input to the LLM, further improving your ability to debug and optimize your application.

By using tracing in Phoenix, you can gain increased visibility into your LLM application, empowering you to identify and address performance bottlenecks, optimize resource utilization, and ensure the overall reliability and effectiveness of your system.

<figure><img src="https://storage.googleapis.com/arize-assets/phoenix/assets/images/trace_details.png" alt=""><figcaption><p>View the inner workings for your LLM Application</p></figcaption></figure>

Expand Down
6 changes: 6 additions & 0 deletions docs/hosted-phoenix.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,9 @@ Currently accounts are setup to be used specifically for one developer. We will
### Pricing

Hosted Phoenix is free for all developers. We will add a paid tier in the future which increases your data retention and also give you access to more storage.

### Are there other demos available?

Yes. This demo and [accompanying blog](https://arize.com/blog/how-to-host-phoenix-persistence/) show how to deploy Phoenix via Docker/Kubernetes:

{% embed url="https://www.youtube.com/watch?v=9hNrosMqirQ" %}
87 changes: 39 additions & 48 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ For details on customizing a local terminal deployment, see [Terminal Setup](htt
{% endtab %}

{% tab title="Docker" %}
Launch your loaded docker image using:
Launch the phoenix docker image using:

```bash
docker run -p 6006:6006 arizephoenix/phoenix:latest
docker run -p 6006:6006 -p 4317:4317 arizephoenix/phoenix:latest
```

This will expose the Phoenix on `localhost:6006`
This will expose the Phoenix UI and REST API on `localhost:6006` and exposes the gRPC endpoint for spans on `localhost:4317`

For more details on customizing a docker deployment, see [#docker](quickstart.md#docker "mention")
For more details on customizing a docker deployment, see [docker.md](deployment/docker.md "mention")
{% endtab %}

{% tab title="Notebook" %}
Expand All @@ -83,83 +83,74 @@ Hosted Phoenix instances are always online. Nothing more to do here!

## Connect your App

To collect traces from your application, you must point your app to your Phoenix instance.
To collect traces from your application, you must configure an OpenTelemetry TracerProvider to send traces to Phoenix. The `register` utility from the `phoenix.otel` module streamlines this process.

{% tabs %}
{% tab title="Local Instance / Docker (Python)" %}
Install packages:
{% tab title="Python" %}
If `arize-phoenix` is not installed in your python environment, you can use `arize-phoenix-otel` to quickly connect to your phoenix instance.

```bash
pip install opentelemetry-sdk opentelemetry-exporter-otlp
pip install arize-phoenix-otel
```

Connect your application to your instance using:

```python
from opentelemetry import trace as trace_api
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk import trace as trace_sdk
from opentelemetry.sdk.trace.export import SimpleSpanProcessor

tracer_provider = trace_sdk.TracerProvider()
span_exporter = OTLPSpanExporter("http://localhost:6006/v1/traces")
span_processor = SimpleSpanProcessor(span_exporter)
tracer_provider.add_span_processor(span_processor)
trace_api.set_tracer_provider(tracer_provider)
from phoenix.otel import register

# defaults to endpoint="http://localhost:4317"
register(
project_name="my-llm-app", # Default is 'default'
endpoint="http://localhost:4317", # Sends traces using gRPC
)
```

See [deploying-phoenix.md](deployment/deploying-phoenix.md "mention") for more details
{% hint style="info" %}
You do not have to use phoenix.otel to connect to your phoenix instance, you can use OpenTelemetry itself to initialize your OTEL connection. See[using-otel-python-directly.md](tracing/how-to-tracing/setup-tracing/setup-tracing-python/using-otel-python-directly.md "mention")
{% endhint %}

See [setup-tracing-python](tracing/how-to-tracing/setup-tracing/setup-tracing-python/ "mention") for more details on configuration and setup
{% endtab %}

{% tab title="TypeScript" %}
For setting up tracing and OpenTelemetry with TypeScript, see [setup-tracing-ts.md](tracing/how-to-tracing/setup-tracing/setup-tracing-ts.md "mention")
{% endtab %}

{% tab title="Notebook" %}
Connect your notebook to Phoenix:

```python
from opentelemetry import trace as trace_api
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk import trace as trace_sdk
from opentelemetry.sdk.trace.export import SimpleSpanProcessor

tracer_provider = trace_sdk.TracerProvider()
span_exporter = OTLPSpanExporter("http://localhost:6006/v1/traces")
span_processor = SimpleSpanProcessor(span_exporter)
tracer_provider.add_span_processor(span_processor)
trace_api.set_tracer_provider(tracer_provider)
from phoenix.otel import register

# defaults to endpoint="http://localhost:4317"
register(
project_name="my-llm-app", # Default is 'default'
endpoint="http://localhost:4317", # Sends traces using gRPC
)
```
{% endtab %}

{% tab title="app.phoenix.arize.com" %}
Install the following dependencies:
If `arize-phoenix` is not installed in your python environment, you can use `arize-phoenix-otel` to quickly connect to your phoenix instance.

```bash
pip install opentelemetry-sdk opentelemetry-exporter-otlp
pip install arize-phoenix-otel
```

Connect your application to your cloud instance using:

```python
import os
from opentelemetry import trace as trace_api
from opentelemetry.sdk import trace as trace_sdk
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (
OTLPSpanExporter as GRPCSpanExporter,
)
from opentelemetry.exporter.otlp.proto.http.trace_exporter import (
OTLPSpanExporter as HTTPSpanExporter,
)
from phoenix.otel import register

# Add Phoenix API Key for tracing
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"api_key={PHOENIX_API_KEY}"

# Add Phoenix
span_phoenix_processor = SimpleSpanProcessor(HTTPSpanExporter(endpoint="https://app.phoenix.arize.com/v1/traces"))

# Add them to the tracer
tracer_provider = trace_sdk.TracerProvider()
tracer_provider.add_span_processor(span_processor=span_phoenix_processor)
trace_api.set_tracer_provider(tracer_provider=tracer_provider)
# configure the Phoenix tracer
register(
project_name="my-llm-app", # Default is 'default'
endpoint="https://app.phoenix.arize.com/v1/traces",
)
```

Your Phoenix API key can be found on the Keys section of your dashboard.
Expand Down
2 changes: 1 addition & 1 deletion docs/quickstart/evals.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ session = px.launch_app(trace=trace_ds)
session.view()
```

You should now see a view like this.
You should now see a view like this. If not, toggle the time range to "All Time" as the default "Last 7 Days" may not adequately represent the time range of the traces.

![A view of the Phoenix UI prior to adding evaluation annotations](https://storage.googleapis.com/arize-assets/phoenix/assets/docs/notebooks/evals/traces\_without\_evaluation\_annotations.png)

Expand Down
6 changes: 3 additions & 3 deletions docs/setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ description: How to get started with Phoenix

## [How to run in different environments](../environments.md)

* Hosted Phoenix by Arize
* [In a Python Notebook](../environments.md#notebooks)
* [Hosted Phoenix by Arize](../hosted-phoenix.md)
* [In a python notebook](../environments.md#notebooks)
* [From the command line](../environments.md#terminal)
* [In a container](../environments.md#container)
* [In a Container](../environments.md#container)

## [How to configure phoenix](configuration.md)

Expand Down
5 changes: 3 additions & 2 deletions docs/setup/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ The following environment variables will control how your phoenix server runs.
* **PHOENIX\_SERVER\_INSTRUMENTATION\_OTLP\_TRACE\_COLLECTOR\_HTTP\_ENDPOINT:** Specifies an HTTP endpoint for the OTLP trace collector. Specifying this variable enables the OpenTelemetry tracer and exporter for the Phoenix server.
* **PHOENIX\_SERVER\_INSTRUMENTATION\_OTLP\_TRACE\_COLLECTOR\_GRPC\_ENDPOINT:** Specifies an gRPC endpoint for the OTLP trace collector. Specifying this variable enables the OpenTelemetry tracer and exporter for the Phoenix server.

### Notebook Configuration
### Client Configuration

The following environment variables will control your notebook environment.
The following environment variables will control your client or notebook environment.

* **PHOENIX\_NOTEBOOK\_ENV:** The notebook environment. Typically you do not need to set this but it can be set explicitly (e.x. `sagemaker`)
* **PHOENIX\_COLLECTOR\_ENDPOINT:** The endpoint traces and evals are sent to. This must be set if the Phoenix server is running on a remote instance. For example if phoenix is running at `http://125.2.3.5:4040` , this environment variable must be set where your LLM application is running and being traced. Note that the endpoint should not contain trailing slashes or slugs.
* **PHOENIX\_PROJECT\_NAME:** The project under which traces will be sent. See [projects](../tracing/how-to-tracing/customize-traces.md#log-to-a-specific-project).
* **PHOENIX\_CLIENT\_HEADERS:** The headers to set when talking to the phoenix server. This might be things like authentication headers for hosted phoenix.
5 changes: 5 additions & 0 deletions docs/tracing/how-to-tracing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ description: Guides on how to use traces

# How-to: Tracing

## [Setup Tracing](setup-tracing/)

* Setup Tracing in [Python](setup-tracing/setup-tracing-python/) or [TypeScript](setup-tracing/setup-tracing-ts.md)
* Add Integrations via [Auto Intstrumentation](./#auto-instrumentation)

## [Tracing Core Concepts](tracing-core-concepts.md)

* [How to log traces](tracing-core-concepts.md#how-to-log-traces)
Expand Down
14 changes: 14 additions & 0 deletions docs/tracing/how-to-tracing/configure-tracing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
description: How to customize OpenTelemetry and OpenInference for your setup
---

# Configure Tracing

### Span Processing

The tutorials and code snippets in these docs default to the `SimpleSpanProcessor.` A `SimpleSpanProcessor` processes and exports spans as they are created. This means that if you create 5 spans, each will be processed and exported before the next span is created in code. This can be helpful in scenarios where you do not want to risk losing a batch, or if you’re experimenting with OpenTelemetry in development. However, it also comes with potentially significant overhead, especially if spans are being exported over a network - each time a call to create a span is made, it would be processed and sent over a network before your app’s execution could continue.

&#x20;The `BatchSpanProcessor` processes spans in batches before they are exported. This is usually the right processor to use for an application in production but it does mean spans may take some time to show up in Phoenix.

In production we recommend the `BatchSpanProcessor` over `SimpleSpanProcessor`\
when deployed and the `SimpleSpanProcessor` when developing.
4 changes: 3 additions & 1 deletion docs/tracing/how-to-tracing/customize-traces.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ description: Oftentimes you want to customize various aspects of traces you log

## Log to a specific project

Phoenix uses [projects](../concepts-tracing.md#projects) to group traces. If left unspecified, all traces are sent to a default project.&#x20;
Phoenix uses [projects](../concepts-tracing.md#projects) to group traces. If left unspecified, all traces are sent to a default project.

{% embed url="https://www.youtube.com/watch?v=GPno92s9WFM" %}

{% tabs %}
{% tab title="Notebook" %}
Expand Down
18 changes: 18 additions & 0 deletions docs/tracing/how-to-tracing/setup-tracing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Setup Tracing

Phoenix uses OTLP (OpenTelemetry Language Protocol) to receive traces from your application. First you will have to setup you application to send traces to phoenix.



<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-cover data-type="files"></th></tr></thead><tbody><tr><td></td><td><a data-mention href="setup-tracing-python/">setup-tracing-python</a></td><td></td><td><a href="../../../.gitbook/assets/python.png">python.png</a></td></tr><tr><td></td><td><a data-mention href="setup-tracing-ts.md">setup-tracing-ts.md</a></td><td></td><td><a href="../../../.gitbook/assets/javascript.png">javascript.png</a></td></tr></tbody></table>

## Next Steps

Phoenix supports many integrations in the form of auto-Instrumentors as well as manually creating spans by instrumenting your code:

[instrumentation](../instrumentation/ "mention")

[manual-instrumentation](../manual-instrumentation/ "mention")

####

Loading

0 comments on commit 7faaba2

Please sign in to comment.