[Live Debugger] Add 10ms snapshot capture timeout circuit breaker#4512
Draft
watson wants to merge 1 commit intographite-base/4512from
Draft
[Live Debugger] Add 10ms snapshot capture timeout circuit breaker#4512watson wants to merge 1 commit intographite-base/4512from
watson wants to merge 1 commit intographite-base/4512from
Conversation
Collaborator
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 79c3335 | Docs | Datadog PR Page | Give us feedback! |
Bundles Sizes Evolution
🚀 CPU Performance
🧠 Memory Performance
|
bf9a162 to
b9da4f3
Compare
54767dd to
57a3752
Compare
57a3752 to
9967454
Compare
b9da4f3 to
0040ee8
Compare
9967454 to
6d55f19
Compare
0040ee8 to
653aee9
Compare
6d55f19 to
92a1c3c
Compare
653aee9 to
7d1efe7
Compare
92a1c3c to
46622ab
Compare
Thread a CaptureContext with a performance.now() deadline through the capture walker so that snapshot serialization aborts early when the budget is exceeded. A single deadline is shared across all probes in a hook invocation; non-snapshot probes are unaffected. When the timeout fires, the snapshot is dropped entirely and capture stops at the next logical checkpoint (property, array element, map entry, etc.). The timeout value uses the real typeof the value, consistent with how all other Datadog tracers handle notCapturedReason.
46622ab to
79c3335
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Motivation
Snapshot capture in the Live Debugger serializes JavaScript values synchronously by walking object graphs recursively. For large or deeply nested objects, this can block the main thread for an unacceptable amount of time. We need a circuit breaker that aborts capture when it takes too long, preventing the debugger from degrading application performance.
Changes
Adds a 10ms cooperative timeout to the snapshot capture path in the Browser Debugger SDK.
capture.tsCaptureContextinterface (deadline+timedOutflag) threaded throughcapture(),captureFields(), and all internal recursive helpers.CaptureContextargument.isTimedOut()checks the flag first (fast path), then callsperformance.now()against the deadline. Checks are placed at coarse logical boundaries: before each object property, array element, map entry, set item, and typed array element iteration.captureValuereturns{ type: <real typeof>, notCapturedReason: 'timeout' }, consistent with how all other Datadog tracers handlenotCapturedReason.api.tsonEntry,onReturn,onThrow) computes a single deadline before the probe loop and shares it across all probes. This means if one snapshot probe exhausts the budget, subsequent snapshot probes exit immediately, while non-snapshot probes are unaffected.Test instructions
Run the debugger unit tests:
Key test scenarios:
capture()returns the realtypeofvalue (including'null'not'object') on timeoutChecklist