Pull Request已成功合入, 合并人@ascend-robot
(感谢 ChaseChe77 的贡献)变更摘要
本 PR(Tracing 系列 2/3)在既有 OpenTelemetry Hook Tracing 基础能力之上,通过现有 Hook 机制接入 vLLM/vLLM-Ascend 业务埋点:新增独立的 Tracing Around Hook,扩展现有 Profiling YAML 配置解析以支持 trace 字段与 Trace-only 模式,并复用 vLLM 全局 OpenTelemetry Provider,将 Hook Span 经 vLLM 配置的 OTLP Endpoint 导出至 Jaeger,全程不修改 vLLM IPC、不侵入其源码、不影响原有 Profiling 能力。
主要改动
- 新增
trace_hook.pyTracing Around Hook: 提供HookTraceSpec、parse_hook_trace_spec与make_trace_around_factory,支持同步/异步函数及call、request、request_context、schedule、model、output语义适配器,支持 Span 名称、Domain、SpanKind 的声明式配置;业务函数异常时记录失败状态并原样抛出原异常,不改变原函数行为。 - 扩展配置加载以支持 Trace-only 模式:
ConfigLoader.load_profiling新增enable_profiling/enable_tracing参数,Profiling YAML 条目可带可选trace字段;Trace-only 模式下不解析、不执行原 Profiling Handler(_profiling_noop_handler),非法 Tracing 配置告警跳过、同一 Symbol 的重复 Tracing 定义去重,Tracing 关闭时保持原有 Profiling 行为不变。 - 隔离 Tracing 与 Profiling 生命周期:
VLLMProfiler新增_profiling_requested/_profiling_active/_tracing_requested状态,由MS_TRACE_ENABLE=1单独控制 Hook Tracing;Trace-only 模式不初始化 Metrics、不导入业务 Handler(register_service_profiler提前返回),Profiling 停止后通过自定义on_start/on_stop回调保留 Tracing Hook。 - 内置 YAML 增加 vLLM/vLLM-Ascend 埋点:
service_profiling_symbols.yaml为vllm.request(SERVER)、vllm.scheduler.schedule、vllm.model.execute、vllm_ascend.model_runner.execute、vllm.output.process配置trace语义;trace_hook.py从trace_headers获取 W3C Trace Context,并用request_id关联请求、调度和模型执行 Span。 - 可靠性修复与 UT 补充:
hook_runtime.py改用itertools.islice限制 Request ID 可迭代对象的消费数量;otel_hook.py的 Perfetto Processor 仅在注册成功后记录 Provider,注册失败按 5 秒退避重试并保持 fail-open;module_hook.py确保业务异常不被当作埋点失败重试而原样抛出。新增/扩展test_hook_tracing.py、test_otel_hook.py、test_module_hook.py覆盖 Trace-only、组合开启、去重及恢复重试等场景。


Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-Ascend/msserviceprofiler | ✅ 刘鹏程, mei-feiyao (2/2) | ✅ 刘鹏程 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
Mad97_, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


ascend docs pipeline is running...


ascend docs pipeline is running...


✅ 跳过 docs ci 检查,没有需要检查的文档文件


✅ 跳过 docs ci 检查,没有需要检查的文档文件


| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_msserviceprofiler_arm | ✅ | >>> |
| Build_msserviceprofiler_x86 | ✅ | >>> | |
| Docs_msserviceprofiler | ✅ | >>> | |
| 恶意代码检查 | Antipoison_msserviceprofiler | ✅ | >>> |
| 编码安全与规范检查 | codecheck_pre-commit | ✅ | >>> |
| pre-commit | ✅ | >>> | |
| 开源片段检查 | SCA_msserviceprofiler | ✅ | >>> |
| 开发者测试 | UT_msserviceprofiler | ✅ | >>> |
| 流水线 | PR-pipeline_msserviceprofiler | ✅ | >>> |
- compile : 运行流水线
- retry : 重试流水线所有失败子任务
- retry <任务名> : 仅重试指定失败子任务
- stop : 停止流水线


/lgtm


PR 合入模板
1. 修改描述
修改原因:
PR #446 已提供 OpenTelemetry Hook Tracing 基础能力,但尚未接入 vLLM/vLLM-Ascend 业务函数,无法生成包含请求、调度、模型执行和输出处理语义的 Hook Span。
本 PR 作为 Tracing 系列第二部分,在不修改 vLLM IPC、不侵入 vLLM/vLLM-Ascend 源码、不影响原有 Profiling 能力的前提下,通过现有 Hook 机制接入 vLLM 业务埋点,并复用 vLLM 全局 OpenTelemetry Provider,将 Hook Span 通过 vLLM 配置的 OTLP Endpoint 导出至 Jaeger。
前置 PR:Tracing 1/3:新增 OpenTelemetry Hook Tracing 基础能力
修改内容:
新增
trace_hook.py,提供独立的 Tracing Around Hook:call、request、request_context、schedule、model、output等语义适配器。扩展现有 Hook 配置加载能力:
trace字段。在内置
service_profiling_symbols.yaml中增加当前 vLLM/vLLM-Ascend 埋点:vllm.requestvllm.scheduler.schedulevllm.model.executevllm_ascend.model_runner.executevllm.output.process复用 vLLM 原生 Tracing 上下文:
trace_headers获取 W3C Trace Context。request_id关联请求、调度和模型执行 Span。隔离 Tracing 与原有 Profiling 生命周期:
MS_TRACE_ENABLE=1单独控制 Hook Tracing。根据前置 PR 检视意见补充可靠性修复:
itertools.islice限制 Request ID 可迭代对象的消费数量,避免完整展开超大可迭代对象。补充 UT,覆盖:
2. 功能验证
49 passed。837 insertions + 52 deletions = 889,低于 1000 行限制。vllm.scheduler.schedule、vllm.model.execute等 Hook Span。error、failed、exception、unavailable或数据丢弃告警。vllm serve启动服务。3. 代码检视
要求:
49 passed。4. 安全自检
典型安全编码问题
trace配置校验名称、Domain、SpanKind 和 Adapter 类型。5. 变更知会
资料修改:
Tracing 3/3PR 提供。service_profiling_symbols.yaml,增加 vLLM/vLLM-Ascend Tracing 业务埋点配置。变更通知(消息知会 + 邮件知会):
6. 冒烟修改
PR 来源: