fix(otel): chat root OTel span on all early-return paths#4265
fix(otel): chat root OTel span on all early-return paths#4265icecrasher321 merged 1 commit intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview For Reviewed by Cursor Bugbot for commit 0105f75. Configure here. |
Greptile SummaryThis PR plugs three OTel span leaks in Confidence Score: 5/5Safe to merge — targeted, well-commented fix with no logic changes outside OTel instrumentation. All three early-return paths are correctly instrumented, double-finish is not possible (early returns exit the async callback normally rather than throwing, so the catch block's otelRoot?.finish() is unreachable on those paths), and the only remaining path before otelRoot starts (the 401 session check) correctly has no span to close. No P0/P1 findings. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[handleUnifiedChatPost] --> B{session valid?}
B -- no --> C[return 401\nno otelRoot yet]
B -- yes --> D[startCopilotOtelRoot]
D --> E[otelContextApi.with]
E --> F[resolveBranch]
F -- NextResponse --> G["★ NEW: setAttribute(status)\nfinish('error')\nreturn branch"]
F -- BranchConfig --> H[resolveOrCreateChat]
H --> I{chatId && !currentChat?}
I -- yes --> J["★ NEW: setAttribute(404)\nfinish('error')\nreturn 404"]
I -- no --> K[acquirePendingChatStream]
K --> L{lock acquired?}
L -- no --> M["★ NEW: setAttribute(409)\nfinish('error', Error)\nreturn 409"]
L -- yes --> N[build context, SSE stream]
N --> O[return SSE Response\nspan finished inside stream]
E -- throws --> P[catch: otelRoot?.finish error\nreturn 500]
Reviews (1): Last reviewed commit: "fix(otel): chat root OTel span on all ea..." | Re-trigger Greptile |
Summary
Chat root OTel span on all early-return paths.
Type of Change
Testing
Tested manually
Checklist