[dop] [error-tracking]: derive debug_id from file content - #470
Open
jhssilva wants to merge 3 commits into
Open
Conversation
🎉 All green!🧪 All tests passed 🔗 Commit SHA: 6ebf91f | Docs | Datadog PR Page | Give us feedback! |
rgaignault
reviewed
Jul 29, 2026
| // but the content, and the debug_id embedded in it, is unaffected. Only the file's | ||
| // prefix is read, since the RUM plugin's injected snippet always lands near the | ||
| // start of the file (see DEBUG_ID_SEARCH_PREFIX_BYTES). | ||
| const fileContent = await readFilePrefix( |
There was a problem hiding this comment.
Suggestion: With esbuild, this runs before the injection onEnd, so it uploads the pre-injection files without ddDebugId. Should't we defer the upload until injection completes.
Author
There was a problem hiding this comment.
For now, we'll be dogfooding in web-ui. We'll do other iterations as needed in future pr's.
We'll keep this in mind.
bcaudan
reviewed
Jul 30, 2026
jhssilva
changed the base branch from
buranmert/rum-debug-id-to-error-tracking
to
master
July 31, 2026 15:03
buranmert
reviewed
Jul 31, 2026
Comment on lines
+137
to
+142
| const fileName = path.basename(file); | ||
| // `file` is already relative to the output directory (and may | ||
| // include subdirectories for nested chunks), matching the | ||
| // relativePath computed for sourcemap uploads in | ||
| // error-tracking/src/sourcemaps/files.ts. Do not collapse it to | ||
| // a basename or debug-id lookups by relative path will never match. | ||
| const fileName = file.split(path.sep).join('/'); |
…e Map The RUM plugin injects a debug_id into every built chunk's own JS content. error-tracking's sourcemap uploader now extracts that debug_id back out of each file when it uploads that file's sourcemap, instead of relying on filename-based coordination between the two plugins. Previously, error-tracking got the debug_id from a side-channel Map that the RUM plugin populated at injection time, keyed by the chunk's filename. Bundlers (webpack/rspack) rename chunks after injection via realContentHash, so by the time error-tracking looked the value up by the chunk's final filename, the key no longer matched — the debug_id was silently dropped for almost every chunk in a real build. Instead of coordinating through a filename-keyed Map, error-tracking now reads each minified file's own content directly and extracts the debug_id from the ddDebugId literal the RUM plugin already embeds inside it. This works no matter what renaming the bundler does afterward, since the debug_id travels with the file's content, not its name.
jhssilva
force-pushed
the
hugo.silva/fix-debug-id-key-path
branch
from
July 31, 2026 15:30
9a8a985 to
9e20c37
Compare
…op unrelated fileName plumbing extractDebugId now takes a file path and owns the read+regex composition directly, instead of sender.ts composing readFilePrefix + extractDebugId itself. Removes the now-unneeded readFilePrefix import from sender.ts. Also reverts the esbuild.ts/xpack.ts fileName changes back to bare basenames — that relative-path plumbing was left over from the old filename-keyed debug_id lookup this PR removes, and nothing in this diff depends on it anymore.
Per review, readFilePrefix had a single call site (debugId.ts) so it didn't warrant living in the shared fs helpers. The byte-limited read is now implemented directly inside debugId.ts. Since debugId.ts's file read is no longer mockable through the shared addFixtureFiles fixture system, its tests (and the one sender.ts test that exercises real debug_id extraction) now write real temp files instead, matching the pattern already used by fs.test.ts's own (now-removed) readFilePrefix tests.
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.
Summary
The RUM plugin injects a
debug_idinto every built chunk's own JS content. This PR makes theerror-trackingplugin extract thatdebug_idback out of each file when it uploads that file's sourcemap, instead of relying on the previous filename-based coordination between the two plugins.Why
Previously,
error-trackinggot thedebug_idfrom a side-channel Map that the RUM plugin populated at injection time, keyed by the chunk's filename. Bundlers (webpack/rspack) rename chunks after injection viarealContentHash, so by the timeerror-trackinglooked the value up by the chunk's final filename, the key no longer matched — thedebug_idwas silently dropped for almost every chunk in a real build.How
Instead of coordinating through a filename-keyed Map,
error-trackingnow reads each minified file's own content directly and extracts thedebug_idfrom theddDebugIdliteral the RUM plugin already embeds inside it. This works no matter what renaming the bundler does afterward, since the debug_id travels with the file's content, not its name.error-tracking/src/sourcemaps/debugId.ts(new):extractDebugId()— regex-extracts the debug_id from a file's content.error-tracking/src/sourcemaps/sender.ts: reads the minified file's content and extracts the debug_id from it, in place of the old Map lookup.plugins/rum/src/index.ts+getSourceCodeContextSnippet.ts: RUM no longer needs to track debug_ids separately — the value already lives in the code it injects.core/src/helpers/fs.ts: newreadFilePrefix()helper, since we only need the first bytes of each file, not the whole thing.plugins/injection/{xpack,esbuild}.ts: keep injected chunk filenames as relative paths for consistency with the rest of the pipeline.Notes
mf_apm_runtime_app, rspack), uploaded to staging: each nested chunk's uploadeddebug_idmatches theddDebugIdliteral embedded in that chunk's own file.