fix(telemetry): Propagate daemon ACP trace context#5047
Merged
doudouOUC merged 1 commit intoJun 12, 2026
Conversation
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
wenshao
approved these changes
Jun 12, 2026
wenshao
left a comment
Collaborator
There was a problem hiding this comment.
No issues found. LGTM! ✅ — qwen3.7-max via Qwen Code /review
Collaborator
Author
|
@qwen-code /review |
Contributor
| _Qwen Code review request accepted. Review is queued in [workflow run](https://github.com/QwenLM/qwen-code/actions/runs/27425035889)._ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
This PR keeps daemon-to-ACP telemetry stitched through prompt dispatch by deriving the ACP prompt metadata
traceparentfrom the active daemon bridge span instead of relying on the global outbound propagator. It also records the generated prompt id on the active daemon HTTP request span and stamps deferred blocked-on-user and hook spans with the owning session id resolved from their logical parent context.The regression coverage exercises the daemon trace metadata injection path, the bridge prompt dispatch span ordering, the daemon prompt id span attribute, and the multi-session session attribution cases for deferred spans.
Why it's needed
qwen serveinstalls a no-op outbound propagator by default, so usingpropagation.inject()for daemon-to-ACP prompt metadata could leave the ACP child interaction without a usable parenttraceparent. The daemon HTTP span also generated apromptIdwithout attaching it to the current request span, and some deferred spans could fall back to a stale process-global session id in multi-session daemon scenarios. Together these gaps made the daemon HTTP span → bridge span → ACP child interaction span chain harder to reconstruct in OTel backends.Reviewer Test Plan
How to verify
Run
cd packages/core && npx vitest run src/telemetry/daemon-tracing.test.ts src/telemetry/session-tracing.test.tsand expect 130 passing tests.Run
cd packages/acp-bridge && npx vitest run src/bridge.test.tsand expect 251 passing tests.Run
cd packages/cli && npx vitest run src/serve/server.test.tsand expect 408 passing tests.Run
npx prettier --check packages/core/src/telemetry/daemon-tracing.ts packages/core/src/telemetry/daemon-tracing.test.ts packages/core/src/telemetry/session-tracing.ts packages/core/src/telemetry/session-tracing.test.ts packages/cli/src/serve/server.ts packages/cli/src/serve/server.test.ts packages/acp-bridge/src/bridge.test.tsand expect all matched files to use Prettier code style.Run
npm run build && npm run typecheckand expect exit code 0. Local output still includes existing VS Code companion curly lint warnings, Browserslist stale-data warnings, and the existing web-shell chunk-size warning.Evidence (Before & After)
N/A
Tested on
Environment (optional)
Node.js v22.22.3, npm 10.9.8.
Risk & Scope
traceparentfrom the active span and continues stripping client-supplied reserved trace metadata;tracestateis not synthesized because this codebase has no internal tracestate source for this path.Linked Issues
Related to #4554.
中文说明
What this PR does
这个 PR 让 daemon 到 ACP 的 prompt dispatch telemetry 链路保持贯通:ACP prompt metadata 里的
traceparent改为从当前 active daemon bridge span 派生,不再依赖全局 outbound propagator。同时,生成的 prompt id 会写到当前 daemon HTTP request span 上,deferred 的 blocked-on-user 和 hook spans 也会从逻辑父上下文解析 owning session id。回归测试覆盖 daemon trace metadata 注入路径、bridge prompt dispatch span 顺序、daemon prompt id span attribute,以及 deferred spans 在多 session 场景下的 session 归因。
Why it's needed
qwen serve默认安装 no-op outbound propagator,因此用propagation.inject()写 daemon 到 ACP 的 prompt metadata 时,ACP child interaction 可能拿不到可用的父级traceparent。daemon HTTP span 也生成了promptId但没有写回当前 request span,部分 deferred spans 在多 session daemon 场景下还可能退回到过期的进程全局 session id。这些缺口会让 OTel 后端里 “daemon HTTP span → bridge span → ACP child interaction span” 链路更难还原。Reviewer Test Plan
How to verify
运行
cd packages/core && npx vitest run src/telemetry/daemon-tracing.test.ts src/telemetry/session-tracing.test.ts,预期 130 个测试通过。运行
cd packages/acp-bridge && npx vitest run src/bridge.test.ts,预期 251 个测试通过。运行
cd packages/cli && npx vitest run src/serve/server.test.ts,预期 408 个测试通过。运行
npx prettier --check packages/core/src/telemetry/daemon-tracing.ts packages/core/src/telemetry/daemon-tracing.test.ts packages/core/src/telemetry/session-tracing.ts packages/core/src/telemetry/session-tracing.test.ts packages/cli/src/serve/server.ts packages/cli/src/serve/server.test.ts packages/acp-bridge/src/bridge.test.ts,预期所有匹配文件符合 Prettier 格式。运行
npm run build && npm run typecheck,预期退出码为 0。本地输出仍包含既有的 VS Code companion curly lint warnings、Browserslist stale-data warnings,以及既有的 web-shell chunk-size warning。Evidence (Before & After)
N/A
Tested on
Environment (optional)
Node.js v22.22.3,npm 10.9.8。
Risk & Scope
traceparent,并继续剥离客户端传入的保留 trace metadata;由于这条路径在代码库里没有内部tracestate来源,因此不会合成tracestate。Linked Issues
关联 #4554。