feat(telemetry): expand daemon telemetry route coverage#4682
Conversation
…ing-slash handling - Add telemetry spans for previously uncovered routes: recap, btw, model, shell, detach, approval-mode, metadata (PATCH), sessions/delete, workspace/init, and workspace MCP routes (restart, add, delete) - Fix trailing-slash mismatch: normalize req.path before matching so requests like `/session/abc/prompt/` produce spans (Express routes them but the old regex missed them) - Fix workspace sessions regex: `.+` → `[^/]+` to prevent cross-segment over-matching 🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
📋 Review SummaryThis PR expands daemon telemetry route coverage to include additional daemon write routes and fixes two matching issues: trailing slash handling and workspace sessions regex over-matching. The changes are focused and well-motivated, improving observability coverage while fixing edge cases that could cause silent telemetry data loss. 🔍 General Feedback
🎯 Specific Feedback🟢 Medium
🔵 Low
✅ Highlights
|
There was a problem hiding this comment.
Pull request overview
This PR extends daemon request telemetry route resolution so more mutation endpoints emit qwen-code.daemon.request spans, and it normalizes request paths to avoid silently missing spans due to a trailing slash.
Changes:
- Normalize
req.path(strip trailing/) before regex matching so routes likePOST /session/:id/prompt/still produce telemetry. - Expand
resolveDaemonTelemetryRouteto include additional session/workspace routes (e.g. recap/btw/model/shell/detach/approval-mode, metadata, sessions/delete, workspace init, workspace MCP routes). - Tighten workspace sessions regex from
.+to[^/]+to avoid cross-segment overmatching.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add telemetry spans for device-flow auth and tool enable routes that were missed in the initial expansion. 🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
wenshao
left a comment
There was a problem hiding this comment.
No issues found. LGTM! ✅ — qwen3.7-max via Qwen Code /review
chiga0
left a comment
There was a problem hiding this comment.
Code Review Overview (AI Generated)
PR: #4682 feat(telemetry): expand daemon telemetry route coverage
Type: Feature (telemetry expansion) + Bug Fix (trailing slash + regex tightening)
Change size: +52/-11 across 1 file
Multi-Round Review (Rounds 0-6): Clean — 0 findings
Round 0 (Design): Correct approach — pure additive route expansion in resolveDaemonTelemetryRoute, trailing-slash normalization, and regex tightening. All three stated goals are addressed.
Round 1 (Architecture): Single function modification, clean pattern. heartbeat correctly excluded per PR description.
Round 2 (Robustness):
req.path.replace(/\/$/, '') || '/'— correctly handles trailing slash AND root path edge case (empty string fallback to/)- All new regex patterns use
[^/]+for ID segments — no cross-segment over-matching sessionActionregex correctly extended withrecap|btw|model|shell|detach|approval-modesessionMetadataPATCH route,mcpRestart/mcpDelete/toolEnable/deviceFlowDeleteall correctly capture and use IDs
Round 3-4 (CI/Security, Performance): N/A — no CI changes, replace() on short path string is trivial cost.
Round 5 (Telemetry): All new routes follow established patterns, sessionId/permissionRequestId correctly extracted, no attribute misassignment.
Round 6 (Undirected): Verified sessions (plural) vs session (singular) distinction intentional, :server/:name/:id placeholders consistent, no dead code paths.
LGTM!
This review was generated by QoderWork AI
Co-authored-by: Shreya <shreyakeshive@google.com>
Summary
resolveDaemonTelemetryRoute覆盖所有 daemon 写路由(除 heartbeat),新增 recap、btw、model、shell、detach、approval-mode、metadata、sessions/delete、workspace/init、workspace MCP 路由的 telemetry spanreq.path后再做 regex 匹配,避免/session/abc/prompt/这类请求静默丢失 span.+→[^/]+,防止跨路径段过度匹配Test plan
qwen-code.daemon.requestspanPOST /session/:id/prompt/),确认 span 正常生成🤖 Generated with Qwen Code