> ## Documentation Index
> Fetch the complete documentation index at: https://ikun.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Arize Phoenix 通过 OpenInference (本地收集器)

## 概览

本示例演示了如何使用 OpenInference 对 Agno 代理进行仪器化，并将跟踪发送到本地 Arize Phoenix 收集器。

## 代码

```python theme={null}
import os

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.yfinance import YFinanceTools
from phoenix.otel import register

# 设置 Arize Phoenix 的本地收集器端点
os.environ["PHOENIX_COLLECTOR_ENDPOINT"] = "http://localhost:6006"

# 配置 Phoenix Tracer
tracer_provider = register(
    project_name="agno-stock-price-agent",  # 默认为 'default'
    auto_instrument=True,  # 自动使用已安装的 OpenInference 仪器化
)

# 创建并配置代理
agent = Agent(
    name="Stock Price Agent",
    model=OpenAIChat(id="gpt-4o-mini"),
    tools=[YFinanceTools()],
    instructions="你是一个股票价格代理。请以股票分析师的风格回答问题。",
    debug_mode=True,
)

# 使用代理
agent.print_response("特斯拉目前的股价是多少？")
```

## 使用

<Steps>
  <Step title="安装依赖项">
    ```bash theme={null}
    pip install agno arize-phoenix openai openinference-instrumentation-agno opentelemetry-sdk opentelemetry-exporter-otlp
    ```
  </Step>

  <Step title="启动本地收集器">
    运行以下命令启动本地收集器：

    ```bash theme={null}
    phoenix serve
    ```
  </Step>

  <Step title="运行代理">
    <CodeGroup>
      ```bash Mac theme={null}
      python cookbook/observability/arize_phoenix_via_openinference_local.py
      ```

      ```bash Windows theme={null}
      python cookbook/observability/arize_phoenix_via_openinference_local.py
      ```
    </CodeGroup>
  </Step>
</Steps>
