Skip to content

✨ [RUM-16925] attach debug IDs from DD_SOURCE_CODE_CONTEXT to error and long task events#4812

Draft
amortemousque wants to merge 3 commits into
mainfrom
aymeric/add-debug-id
Draft

✨ [RUM-16925] attach debug IDs from DD_SOURCE_CODE_CONTEXT to error and long task events#4812
amortemousque wants to merge 3 commits into
mainfrom
aymeric/add-debug-id

Conversation

@amortemousque

Copy link
Copy Markdown
Collaborator

Motivation

Part of the sourcemap unminification project. When a Datadog bundler plugin is used, it injects DD_SOURCE_CODE_CONTEXT on the window with per-bundle metadata (service, version, debug ID). This PR makes the RUM SDK read the ddDebugId field from that context and attach it to error and long task events as _dd.debug_ids, enabling the backend to correlate events with uploaded sourcemaps.

Changes

  • Move sourceCodeContext from browser-rum-core to browser-core so both the error pipeline and the RUM assembly layer can access it
  • Rename the MFE-specific context hook to sourceCodeMfeContext (clearer scope)
  • In computeRawError: resolve debug_ids by looking up all stack frame URLs in DD_SOURCE_CODE_CONTEXT and attach them as _dd.debug_ids on error events
  • In longTaskCollection: same lookup on script.sourceURL for Long Animation Frame events
  • Export getDebugIds and getSourceCodeContext from @datadog/browser-core

Test instructions

  1. Set window.DD_SOURCE_CODE_CONTEXT with a stack entry whose top-frame URL matches a script URL on the page and a ddDebugId value
  2. Trigger an error or long task from that script
  3. Verify the intake event has _dd.debug_ids: { [scriptUrl]: debugId }

The E2E tests cover both flows automatically (yarn test:e2e -g "debug ID").

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

amortemousque and others added 2 commits June 19, 2026 15:31
- Move sourceCodeContext from browser-rum-core to browser-core so all packages can access it
- Rename MFE-specific context to sourceCodeMfeContext
- Attach debug IDs (from DD_SOURCE_CODE_CONTEXT) to raw errors and long tasks via stack trace URL lookup

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- errors.scenario: verify _dd.debug_ids is populated on error events from DD_SOURCE_CODE_CONTEXT
- microfrontend.scenario: verify _dd.debug_ids on MFE runtime errors and LOAf events

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jun 19, 2026

Copy link
Copy Markdown

Pipelines  Tests

Fix all issues with BitsAI

⚠️ Warnings

🚦 7 Pipeline jobs failed

DataDog/browser-sdk | e2e: [chromium-pinned]   View in Datadog   GitLab

🧪 2 Tests failed

microfrontend › RUM debug_id attribution › errors from console.error should have debug_id from source code context from microfrontend.scenario.ts   View in Datadog
expect(received).toHaveLength(expected)

[chromium-pinned] › microfrontend.scenario.ts:434:15 › microfrontend › RUM debug_id attribution › errors from console.error should have debug_id from source code context 

    Error: expect(received).toHaveLength(expected)

    Expected length: 2
    Received length: 1
    Received array:  [{&#34;_dd&#34;: {&#34;configuration&#34;: {&#34;profiling_sample_rate&#34;: 0, &#34;session_replay_sample_rate&#34;: 100, &#34;session_sample_rate&#34;: 100, &#34;trace_sample_rate&#34;: 100}, &#34;drift&#34;: 0, &#34;format_version&#34;: 2, &#34;sdk_name&#34;: &#34;rum&#34;}, &#34;action&#34;: {&#34;id&#34;: [&#34;0cd6531e-b5fc-4fb3-90f2-ca469b424ec8&#34;, &#34;6ad118bd-4879-4457-b4d9-29125ba571ce&#34;]}, &#34;application&#34;: {&#34;id&#34;: &#34;37fe52bf-b3d5-4ac7-ad9b-44882d479ec8&#34;}, &#34;connectivity&#34;: {&#34;effective_type&#34;: &#34;4g&#34;, &#34;status&#34;: &#34;connected&#34;}, &#34;context&#34;: {&#34;handlingStack&#34;: &#34;HandlingStack: console error
      at HTMLButtonElement.&lt;anonymous&gt; @ http://172.28.224.205:9250/microfrontend/chunks/__federation_expose_app1-b2c0695cc05141242e6b-app1.js:64:17&#34;, &#34;run_id&#34;: &#34;1793386671&#34;, &#34;test_name&#34;: &#34;microfrontend.scenario.ts &gt; microfrontend &gt; RUM debug_id attribution &gt; errors from console.error should have debug_id from source code context&#34;}, &#34;date&#34;: 1782158095225, &#34;ddtags&#34;: &#34;sdk_version:dev,service:main-service,version:1.0.0&#34;, &#34;display&#34;: {&#34;viewport&#34;: {&#34;height&#34;: 720, &#34;width&#34;: 1280}}, &#34;error&#34;: {&#34;handling&#34;: &#34;handled&#34;, &#34;handling_stack&#34;: &#34;HandlingStack: console error
...
microfrontend › RUM debug_id attribution › runtime errors should have debug_id from source code context from microfrontend.scenario.ts   View in Datadog
expect(received).toBeDefined()

[chromium-pinned] › microfrontend.scenario.ts:449:15 › microfrontend › RUM debug_id attribution › runtime errors should have debug_id from source code context 

    Error: expect(received).toBeDefined()

    Received: undefined

      456 |
      457 |         expect(intakeRegistry.rumErrorEvents).toHaveLength(2)
...

DataDog/browser-sdk | e2e: [firefox]   View in Datadog   GitLab

🧪 2 Tests failed

microfrontend › RUM debug_id attribution › errors from console.error should have debug_id from source code context from microfrontend.scenario.ts   View in Datadog
expect(received).toHaveLength(expected)

[firefox] › microfrontend.scenario.ts:434:15 › microfrontend › RUM debug_id attribution › errors from console.error should have debug_id from source code context 

    Error: expect(received).toHaveLength(expected)

    Expected length: 2
    Received length: 1
    Received array:  [{&#34;_dd&#34;: {&#34;configuration&#34;: {&#34;profiling_sample_rate&#34;: 0, &#34;session_replay_sample_rate&#34;: 100, &#34;session_sample_rate&#34;: 100, &#34;trace_sample_rate&#34;: 100}, &#34;drift&#34;: -1, &#34;format_version&#34;: 2, &#34;sdk_name&#34;: &#34;rum&#34;}, &#34;action&#34;: {&#34;id&#34;: [&#34;9262229e-1124-4630-a317-c8b9acdb5fa3&#34;, &#34;9c4e7966-8331-482f-9a2d-246136e996be&#34;]}, &#34;application&#34;: {&#34;id&#34;: &#34;37fe52bf-b3d5-4ac7-ad9b-44882d479ec8&#34;}, &#34;connectivity&#34;: {&#34;status&#34;: &#34;connected&#34;}, &#34;context&#34;: {&#34;handlingStack&#34;: &#34;HandlingStack: console error
      at ./common.ts/createApp/&lt; @ http://172.28.195.94:9364/microfrontend/chunks/__federation_expose_app1-b2c0695cc05141242e6b-app1.js:64:17
...
microfrontend › RUM debug_id attribution › runtime errors should have debug_id from source code context from microfrontend.scenario.ts   View in Datadog
expect(received).toBeDefined()

[firefox] › microfrontend.scenario.ts:449:15 › microfrontend › RUM debug_id attribution › runtime errors should have debug_id from source code context 

    Error: expect(received).toBeDefined()

    Received: undefined

      456 |
      457 |         expect(intakeRegistry.rumErrorEvents).toHaveLength(2)
...

DataDog/browser-sdk | e2e: [webkit-pinned]   View in Datadog   GitLab

🧪 2 Tests failed

microfrontend › RUM debug_id attribution › errors from console.error should have debug_id from source code context from microfrontend.scenario.ts   View in Datadog
expect(received).toHaveLength(expected)

[webkit-pinned] › microfrontend.scenario.ts:434:15 › microfrontend › RUM debug_id attribution › errors from console.error should have debug_id from source code context 

    Error: expect(received).toHaveLength(expected)

    Expected length: 2
    Received length: 0
    Received array:  []

...
microfrontend › RUM debug_id attribution › runtime errors should have debug_id from source code context from microfrontend.scenario.ts   View in Datadog
expect(received).toBeDefined()

[webkit-pinned] › microfrontend.scenario.ts:449:15 › microfrontend › RUM debug_id attribution › runtime errors should have debug_id from source code context 

    Error: expect(received).toBeDefined()

    Received: undefined

      456 |
      457 |         expect(intakeRegistry.rumErrorEvents).toHaveLength(2)
...

View all 7 failed jobs.

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 80.77%
Overall Coverage: 76.92% (+0.06%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 5fa0ed2 | Docs | Datadog PR Page | Give us feedback!

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jun 19, 2026

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 172.46 KiB 172.84 KiB +381 B +0.22%
Rum Profiler 8.22 KiB 8.22 KiB 0 B 0.00%
Rum Recorder 21.09 KiB 21.09 KiB 0 B 0.00%
Logs 54.47 KiB 54.90 KiB +443 B +0.79%
Rum Slim 129.97 KiB 130.25 KiB +288 B +0.22%
Worker 22.96 KiB 22.96 KiB 0 B 0.00%

@amortemousque amortemousque changed the title ✨ attach debug IDs from DD_SOURCE_CODE_CONTEXT to error and long task events ✨ [RUM-16925] attach debug IDs from DD_SOURCE_CODE_CONTEXT to error and long task events Jun 22, 2026
…uota_reason on profiling

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@amortemousque amortemousque force-pushed the aymeric/add-debug-id branch from 0dc95c6 to 5fa0ed2 Compare June 22, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant