# PR #23940 完整报告

- 仓库：`sgl-project/sglang`
- 标题：[AMD] Fix CI RuntimeError: opentelemetry package is not installed
- 合并时间：2026-04-29 18:02
- 原文链接：http://prhub.com.cn/sgl-project/sglang/pull/23940

---

# 执行摘要

- 一句话：修复 AMD ROCm CI 因缺少 tracing 依赖失败
- 推荐动作：值得快速合并的配置修复 PR，逻辑清晰，验证充分。对于其他平台开发者，建议检查是否也需要将 tracing 加入对应的 all 组以避免未来 CI 失败。

# 功能与动机

AMD ROCm CI 在多条 job（multimodal-gen-test-1-gpu-amd、multimodal-gen-test-2-gpu-amd）中所有 tracing 相关测试均失败，报错 `RuntimeError: opentelemetry package is not installed!!!`。此问题源于 OpenTelemetry tracing 功能加入后，ROCm 安装路径未正确包含 tracing 可选依赖。PR body 明确指出了根因并引用相关 PR #21254 和 #21740。

# 实现拆解

1. **`python/pyproject_other.toml` 修改**：在第 170 行的 `all_hip` 依赖列表中添加 `"sglang[tracing]"`，使得 `python[all_hip]` 安装时自动拉取 opentelemetry 相关包。该 tracing extra 已在同一文件第 84-89 行定义，包含 `opentelemetry-sdk`、`opentelemetry-api`、`opentelemetry-exporter-otlp`、`opentelemetry-exporter-otlp-proto-grpc`。
2. **`scripts/ci/amd/amd_ci_install_dependency.sh` 修改**：将 CI 安装的 extras 从 `dev_hip` 改为 `dev_hip,tracing`，确保 CI 环境显式安装 tracing 依赖。同时修复了条件分支中 extras 拼接逻辑，避免 `OPTIONAL_DEPS` 存在时覆盖 tracing。
3. 无需修改 Dockerfile，因为 ROCm Dockerfile 使用 `python[all_hip]` 安装，`all_hip` 现已包含 tracing。

关键文件：
- `python/pyproject_other.toml`（模块 项目配置；类别 config；类型 configuration）: 核心配置变更：在 all_hip 依赖组中添加 sglang[tracing]，修复 AMD ROCm 安装缺失 tracing 依赖的根因。
- `scripts/ci/amd/amd_ci_install_dependency.sh`（模块 CI 脚本；类别 infra；类型 infrastructure）: CI 脚本适配：更新 extras 变量显式包含 tracing，确保 CI 环境安装 tracing 依赖。

关键符号：未识别

## 关键源码片段

### `scripts/ci/amd/amd_ci_install_dependency.sh`

CI 脚本适配：更新 extras 变量显式包含 tracing，确保 CI 环境安装 tracing 依赖。

```bash
# scripts/ci/amd/amd_ci_install_dependency.sh
# 从 OPTIONAL_DEPS 参数构建 python extras 列表，
# 显式包含 tracing 以确保 opentelemetry 包被安装。
OPTIONAL_DEPS="${1:-}"

# 当前 extras 始终包含 tracing
EXTRAS="dev_hip,tracing"

if [ -n "$OPTIONAL_DEPS" ]; then
    # 当有额外依赖时，保留 tracing 并追加 OPTIONAL_DEPS
    EXTRAS="dev_hip,tracing,${OPTIONAL_DEPS}"
fi

echo "Installing python extras: [${EXTRAS}]"

```

# 评论区精华

Gemini 代码审查 bot 提出扩展建议：将 `sglang[tracing]` 同样加入 `all_hpu`、`all_musa`、`all_mps` 以保持一致性，并考虑加入 `test` extra 以确保测试环境依赖完整。该建议未被采纳，理由可能是当前仅 AMD ROCm CI 出现失败，且其他平台暂无相关测试，保持最小化修改。

- 是否应同步修改其他平台的 all 组 (design): 未采纳。当前仅 AMD ROCm CI 出现失败，其他平台暂无 tracing 测试，最小化修改原则。

# 风险与影响

- 风险：变更极小（仅两处配置），风险极低。可能的风险是其他平台（HPU、MUSA、MPS）若后续添加 tracing 测试也会遇到类似问题，但当前无影响。无回归或性能风险。
- 影响：直接修复 AMD ROCm CI 的 tracing 测试失败，影响所有 AMD ROCm CI 流水线。对用户无直接影响（仅为基础设施依赖修复），对系统无性能影响。团队后续需关注其他平台是否也需要类似修复。
- 风险标记：仅影响 AMD ROCm CI, 其他平台可能存在相同遗漏

# 关联脉络

- PR #21254 [Feature] Add OpenTelemetry tracing to diffusion pipeline: 引入 tracing 功能的 PR，导致 tracing 依赖在非 CUDA 平台缺失。
- PR #21740 [Test] Add CI tests for tracing: 添加 tracing CI 测试的 PR，触发 AMD ROCm CI 失败。
- PR #23960 ci: clean up stale-CUDA mooncake variant in install_extra_deps: 同为 CI 依赖安装脚本修复的近期 PR，体现 CI 基础设施持续维护。