feat(telemetry): add client_id attribute and permission route spans#4628
Conversation
📋 Review SummaryThis PR adds telemetry coverage for daemon HTTP request spans by introducing 🔍 General Feedback
🎯 Specific Feedback🟢 Medium
// Current inline logic:
const rawClientId = req.get(CLIENT_ID_HEADER);
const clientId =
rawClientId !== undefined &&
rawClientId !== '' &&
rawClientId.length <= MAX_CLIENT_ID_LENGTH &&
CLIENT_ID_RE.test(rawClientId)
? rawClientId
: undefined;
// Could be:
const rawClientId = req.get(CLIENT_ID_HEADER);
const clientId = parseClientIdHeader(req, res) ?? undefined;
// Note: parseClientIdHeader sends 400 response on invalid, so adjust as needed🔵 Low
✅ Highlights
|
There was a problem hiding this comment.
Pull request overview
Adds additional OpenTelemetry span attributes and span coverage to improve daemon/bridge observability in qwen serve, specifically identifying the daemon client and permission-vote requests.
Changes:
- Add
qwen-code.client_idspan attribute to daemon HTTP request spans (validated fromX-Qwen-Client-Id) and bridgeprompt.dispatchspans (fromBridgeClientRequestContext.clientId). - Add daemon request-span routing + attributes for permission vote endpoints, including
qwen-code.daemon.permission.request_id. - Export
addDaemonRequestAttribute()helper and add/adjust unit tests to cover the new attributes and helper behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/telemetry/index.ts | Re-exports addDaemonRequestAttribute from daemon tracing utilities. |
| packages/core/src/telemetry/daemon-tracing.ts | Adds optional clientId + permissionRequestId request-span attributes and introduces addDaemonRequestAttribute(). |
| packages/core/src/telemetry/daemon-tracing.test.ts | Extends daemon tracing tests to cover new attributes and the new helper. |
| packages/cli/src/serve/server.ts | Extends daemon telemetry middleware route resolution to include permission vote routes and enriches request spans with validated client id + permission request id. |
| packages/acp-bridge/src/bridge.ts | Adds qwen-code.client_id to prompt.dispatch span attributes when client context is present. |
| packages/acp-bridge/src/bridge.test.ts | Updates telemetry test to assert client_id propagation on prompt.dispatch. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Maintainer Verification ReportReviewer: @wenshao Build
Unit Tests
New Test Coverage
Code Review NotesChanges are well-scoped and correct:
No concerns found: No security issues (input is validated before use), no breaking changes, no unnecessary abstractions. The Verdict✅ Ready to merge — all builds and tests pass, code is clean, well-tested, and consistent with existing patterns. |
…o daemon telemetry Add qwen-code.client_id span attribute to daemon HTTP request spans and bridge prompt.dispatch spans. Add telemetry coverage for permission vote routes (POST /session/:id/permission/:requestId, POST /permission/:requestId). Add addDaemonRequestAttribute helper for post-rebase promptId enrichment. 🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
a752447 to
cea3628
Compare
Summary
qwen-code.client_idspan attribute to daemon HTTP request spans (fromX-Qwen-Client-Idheader, validated withCLIENT_ID_RE) and bridgeprompt.dispatchspans (fromBridgeClientRequestContext.clientId)POST /session/:id/permission/:requestIdandPOST /permission/:requestId, withqwen-code.daemon.permission.request_idspan attributeaddDaemonRequestAttribute()helper for post-rebasepromptIdenrichment (plumbing for feat(telemetry): cover qwen serve daemon end-to-end with OpenTelemetry #4554 scope item)Test plan
packages/coredaemon-tracing tests: 8 passed (4 new — clientId/permissionRequestId inclusion/omission, addDaemonRequestAttribute active/no-op)packages/acp-bridgebridge tests: 196 passed (existing telemetry test updated to verifyclient_idflows throughprompt.dispatchspan)🤖 Generated with Qwen Code