名称: phoenix-tracing 描述: OpenInference 语义约定和仪器化,用于凤凰 AI 可观测性。当实施 LLM 跟踪、创建自定义 span 或部署到生产环境时使用。 许可证: Apache-2.0 元数据: 作者: oss@arize.com 版本: “1.0.0” 语言: Python, TypeScript
Phoenix Tracing
全面指南,用于使用 Phoenix 中的 OpenInference 跟踪仪器化 LLM 应用。包含规则文件,涵盖设置、仪器化、span 类型和生产部署。
何时应用
参考这些指南当:
- 设置凤凰跟踪(Python 或 TypeScript)
- 为 LLM 操作创建自定义 span
- 添加遵循 OpenInference 约定的属性
- 部署跟踪到生产环境
- 查询和分析跟踪数据
规则类别
| 优先级 | 类别 | 描述 | 前缀 |
|---|---|---|---|
| 1 | 设置 | 安装和配置 | setup-* |
| 2 | 仪器化 | 自动和手动跟踪 | instrumentation-* |
| 3 | Span 类型 | 9 种 span 种类及其属性 | span-* |
| 4 | 组织 | 项目和会话 | projects-*, sessions-* |
| 5 | 丰富 | 自定义元数据 | metadata-* |
| 6 | 生产 | 批处理、掩码 | production-* |
| 7 | 反馈 | 注释和评估 | annotations-* |
快速参考
1. 设置(从这里开始)
setup-python- 安装 arize-phoenix-otel,配置端点setup-typescript- 安装 @arizeai/phoenix-otel,配置端点
2. 仪器化
instrumentation-auto-python- 自动仪器化 OpenAI, LangChain 等instrumentation-auto-typescript- 自动仪器化支持框架instrumentation-manual-python- 使用装饰器创建自定义 spaninstrumentation-manual-typescript- 使用包装器创建自定义 span
3. Span 类型(带有完整属性模式)
span-llm- LLM API 调用(模型、令牌、消息、成本)span-chain- 多步工作流和管道span-retriever- 文档检索(文档、分数)span-tool- 函数/API 调用(名称、参数)span-agent- 多步推理代理span-embedding- 向量生成span-reranker- 文档重新排名span-guardrail- 安全检查span-evaluator- LLM 评估
4. 组织
projects-python/projects-typescript- 按应用分组跟踪sessions-python/sessions-typescript- 跟踪对话
5. 丰富
metadata-python/metadata-typescript- 自定义属性
6. 生产(关键)
production-python/production-typescript- 批处理、PII 掩码
7. 反馈
annotations-overview- 反馈概念annotations-python/annotations-typescript- 向 span 添加反馈
参考文件
fundamentals-overview- 跟踪、span、属性基础fundamentals-required-attributes- 每 span 类型所需字段fundamentals-universal-attributes- 通用属性(user.id, session.id)fundamentals-flattening- JSON 扁平化规则attributes-messages- 聊天消息格式attributes-metadata- 自定义元数据模式attributes-graph- 代理工作流属性attributes-exceptions- 错误跟踪
常见工作流
- 快速启动:
setup-{lang}→instrumentation-auto-{lang}→ 检查 Phoenix - 自定义 Span:
setup-{lang}→instrumentation-manual-{lang}→span-{type} - 会话跟踪:
sessions-{lang}用于对话分组模式 - 生产:
production-{lang}用于批处理、掩码和部署
如何使用此技能
导航模式:
# 按类别前缀
rules/setup-* # 安装和配置
rules/instrumentation-* # 自动和手动跟踪
rules/span-* # Span 类型规范
rules/sessions-* # 会话跟踪
rules/production-* # 生产部署
rules/fundamentals-* # 核心概念
rules/attributes-* # 属性规范
# 按语言
rules/*-python.md # Python 实现
rules/*-typescript.md # TypeScript 实现
阅读顺序:
- 从
setup-{lang}开始针对你的语言 - 选择
instrumentation-auto-{lang}或instrumentation-manual-{lang} - 根据需要参考
span-{type}文件用于特定操作 - 查看
fundamentals-*文件获取属性规范
参考
Phoenix 文档:
Python API 文档:
- Python OTEL 包 -
arize-phoenix-otelAPI 参考 - Python 客户端包 -
arize-phoenix-clientAPI 参考
TypeScript API 文档:
- TypeScript 包 -
@arizeai/phoenix-otel,@arizeai/phoenix-client, 和其他 TypeScript 包