mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-04 08:09:27 +00:00
## Problem A **successful** AI review shows up as a **red 25-minute CI timeout**. Two plumbing bugs, both proven from run logs: **1. Trace-export hang** (OSS #13875) ``` 10:19:53 AI Code Review complete ← review posted in 147s 10:19:53 Exporting 14 trace spans to OpenObserve... 10:20:53 Trace export failed: Span processor did not complete within 60000 ms Error: The operation was canceled ← job killed 25 min later ``` After the comment is posted, `TRACE.flush()` exports OTel spans. If OpenObserve is slow/unreachable, `forceFlush()` times out and throws, so `shutdown()` never runs — the `BatchSpanProcessor` timer + exporter sockets stay open and keep Node alive until the job's 25-min timeout. **2. Update-404** (OSS #13871) ``` Updating existing review comment #5336607219 Fatal error: gh api ... PATCH ... gh: Not Found (HTTP 404) ``` If the captured review comment is deleted mid-run, the PATCH 404s and fatal-errors the whole run. ## Fix (plumbing only — review logic untouched) 1. Bound `forceFlush()` **and** `shutdown()` against a 15s deadline (deadline timer `.unref()`'d), always run `shutdown()` in a `finally`, and **`process.exit()` explicitly** after flush so lingering OTel handles can't keep the process alive. 2. On a 404 from the comment PATCH, **fall back to posting a fresh comment**. ## Verified - `node --check` passes. - Runtime repro with an **unreachable trace endpoint**: the process exits cleanly (code 1) instead of hanging to the 25-min job timeout. ## Review feedback (addressed) - 🟡 **Flush deadline no longer hardcoded to 15s.** It's now `Math.max(traceExportTimeoutMs() + 5_000, 15_000)`, so the outer race sits above the configured `forceFlushTimeoutMillis` — a healthy-but-slow OpenObserve gets its full `O2_TRACE_EXPORT_TIMEOUT_MS` window (default 60s) and the precise inner timeout fires first. **Behavior note:** an unreachable endpoint now exits in ~65s at the default config instead of 15s (still well under the 25-min cap); lower `O2_TRACE_EXPORT_TIMEOUT_MS` for a faster exit. - 🔵 **Accurate comment-span attribution.** `updateReviewComment`/`postReviewComment` now return the real `{action, id}`, so the `github.pr.review_comment` span records `create` + the new comment id on a 404 fallback instead of the stale `update` + deleted id. Engine logic in this change is identical across OSS/ENT. (Note: the ENT branch has since merged the OpenObserve Code Review branding from `main`, so the full file is no longer byte-identical to OSS — only the plumbing touched here is.) No change to what the reviewer finds or decides.