Repository navigation
fix(ivm): platform-error alert misses the first error burst on a fresh isolate - #5373
Conversation
…h isolate transformer_ivm_platform_error is created lazily on its first increment, so a series appears already at a non-zero value. rate()/increase() anchor on the first sample in their window and cannot measure the jump that *creates* a series — so an error burst on a workspace/isolate seen for the first time is invisible to the ivm-platform-errors alert, which only trips on the second increment of an already-established series. A single burst that then goes quiet is never alerted, and increase-based panels undercount it. Seed the counter at 0 on the happy path of IvmScriptRunner.execute, using the same label set the error path increments. Any workspace actively processing now has its error series present at 0 before it can fail, giving increase() the 0 -> N edge it needs to catch the very first burst. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Warning Review limit reached
Next review available in: 45 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Note
|
| Layer / File(s) | Summary |
|---|---|
Metric seeding and isolate creation src/util/ivm/scriptRunner.ts |
execute passes shared metric tags and a creation callback to getOrCreate; new isolate creation seeds the counter, while failures increment it. |
Metric behavior validation src/util/ivm/scriptRunner.test.ts, src/util/prometheus.test.js |
Mocked tests cover successful execution, failures, cache reuse, concurrent creation, eviction, matching labels, and non-resetting zero seeds. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Sequence Diagram(s)
sequenceDiagram
participant IvmScriptRunner
participant getOrCreate
participant IVMCache
participant stats
IvmScriptRunner->>getOrCreate: request isolate with cache key
getOrCreate->>stats: seed ivm_platform_error at 0
getOrCreate->>IVMCache: create or reuse isolate
IvmScriptRunner->>stats: increment metric on failure
Possibly related PRs
- rudderlabs/rudder-transformer#5348: Modifies the same
IvmScriptRunner.executeandgetOrCreateisolate lifecycle.
Suggested reviewers: maheshkutty
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title clearly summarizes the main fix: seeding platform-error metrics so the first burst on a fresh isolate is alertable. |
| Description check | ✅ Passed | The description is strong and covers the required change context, but it omits the required Linear task reference. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Commit unit tests in branch
fix/int-6832-ivm-platform-error-counter-zero-init
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
… per call Move the 0-seed from every execute() into the cache-miss (isolate build) path so warm-isolate calls never touch the metrics registry. A workspace's first call is always a cache miss, so the 0 baseline is still materialised before any error can occur — increase() still gets its 0 -> N edge — while the hot path does no per-call metrics work. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…eset Address review feedback on the platform-error 0-seed tests: - scriptRunner.test.ts: add a concurrent first-callers test (two calls for the same key coalesce to one 0-seed and one isolate build) and a re-seed-after-eviction test (an error evicts the isolate; the next call rebuilds and re-seeds 0). These are the branches most likely to regress under refactor. - scriptRunner.test.ts: document that the mocked `stats.counter`/`increment` are independent, whereas in prod `increment` delegates to `counter(name, 1)` — so total `counter` call counts must not be asserted across error paths. - prometheus.test.js: new, proves against the real registry that `counter(name, 0)` materialises a series at 0 and that re-seeding with 0 after an increment does not reset the accumulated count (inc(0) is add-only). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The platform-error 0-seed added in this PR makes IvmScriptRunner.execute
call stats.counter('ivm_platform_error', 0, ...) on every isolate build.
The custom_audience ivmScriptRunner suite mocks stats without a counter
field, so onCreate() threw 'stats.counter is not a function' on the first
call of every test, breaking the whole suite. Add counter: jest.fn() to
the mock so it matches the real stats surface the runner now uses.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #5373 +/- ##
===========================================
+ Coverage 92.87% 92.88% +0.01%
===========================================
Files 706 708 +2
Lines 38372 38431 +59
Branches 9005 8970 -35
===========================================
+ Hits 35638 35697 +59
- Misses 2508 2524 +16
+ Partials 226 210 -16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
The branch had drifted 13 commits behind develop and was CONFLICTING, which meant GitHub could not compute a merge ref and silently skipped every pull_request-triggered workflow — DT Tests, Verify and Tests have never run on this PR. Only commitlint (push-triggered) and CodeQL reported, so the PR appeared green while its unit tests had never executed once. Conflicts were confined to the two files this branch touches, against #5373 ("platform-error alert misses the first error burst on a fresh isolate"), which landed on develop and rewrote the same execute()/getOrCreate() methods. The two changes are complementary: - scriptRunner.ts: keep both. `platformErrorTags` and the 0-seed callback from develop, plus this branch's acquireSlot()/releaseSlot() gate around them. The tags object is a side-effect-free literal, so hoisting it above the slot acquisition is safe, and seeding still happens once per isolate build — now inside the gated path, after a slot is held. - scriptRunner.test.ts: add/add. The suites need incompatible module mocks — develop's stubs `fs` and `DisposableCache`, while the gate tests exercise the real cache so gate teardown can be observed against real eviction. Merging them into one file would break both, so develop's file is kept as-is and the gate suite moves to scriptRunner.gate.test.ts. Its `stats` mock gains `counter`, which execute() now calls via develop's 0-seed callback. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>



What
The
ivm-platform-errorsalert can silently miss the first burst of isolated-vm platform errors on a workspace/isolate that hasn't errored before — the exact failure mode we hit in a recent enterprise-eu incident, where a burst of ~2.7k errors on a freshly-seen isolate never showed up and only a later, smaller burst tripped the alert.Why it happens
transformer_ivm_platform_erroris created lazily on its first increment, so its series springs into existence already at a non-zero value.rate()/increase()anchor on the first sample within their window and cannot measure the jump that creates a series — there is no earlier sample to diff against. As a result:sum by (cluster, namespace, functionName) (increase(transformer_ivm_platform_error[1m])) > 0) only trips on the second increment of an already-established series;increase()-based dashboard panels undercount the same bursts.Replaying the alert expression over the incident confirmed it: the first burst's window evaluated to
0throughout, and only the second increment produced a non-zero value.Fix
Materialise the counter at
0for a label set when its isolate is first built (the cache-miss path ofIvmScriptRunner.execute), using the same labels the error path increments. Because a workspace's first call is always a cache miss, the0baseline exists before any error can occur, soincrease()sees a clean0 → Nedge and catches the very first burst.Seeding on isolate build (rather than on every call) keeps the warm-isolate hot path off the metrics registry entirely — the
0is written once per isolate lifecycle, not per event. This is the same zero-initialisation approach already used elsewhere in the transformer for counters that feed alerts.Tradeoffs & scope
(workspaceId, functionName, cache), not only erroring ones. It is bounded by the active workspaces per pod.workspaceIdwas already a label on this metric, so no new label dimension is introduced.0is ever scraped), that one burst can still be missed. This is far narrower than the previous behaviour (every freshly-seen series was blind) and is inherent to lazily-created counters.Testing
New
scriptRunner.test.tscovers:0and records no error;0and increments with a matching label set;The existing
sandboxClientintegration suite exercises the seeded build path.