Skip to content

Conversation

@bcaudan
Copy link
Collaborator

@bcaudan bcaudan commented Oct 23, 2025

Motivation

In the context of micro frontend support, we add the ability to enrich events with source code context (service and version) from window.DD_SOURCE_CODE_CONTEXT.
DD_SOURCE_CODE_CONTEXT is injected at build time by the build plugin.

Changes

  • Add sourceCodeContext.ts.
  • Add rawRumEvent and domainContext to the assemble hook parameters to allow extracting the stack for sourceCodeContext.

Test instructions

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.

@cit-pr-commenter
Copy link

cit-pr-commenter bot commented Oct 23, 2025

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 164.35 KiB 165.28 KiB +956 B +0.57%
Rum Profiler 4.33 KiB 4.33 KiB 0 B 0.00%
Rum Recorder 20.04 KiB 20.04 KiB 0 B 0.00%
Logs 56.14 KiB 56.21 KiB +72 B +0.13%
Flagging 944 B 944 B 0 B 0.00%
Rum Slim 121.57 KiB 122.46 KiB +918 B +0.74%
Worker 23.63 KiB 23.63 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base CPU Time (ms) Local CPU Time (ms) 𝚫%
RUM - add global context 0.0048 0.0056 +16.67%
RUM - add action 0.0146 0.0206 +41.10%
RUM - add error 0.0134 0.0301 +124.63%
RUM - add timing 0.0031 0.0047 +51.61%
RUM - start view 0.0036 0.0037 +2.78%
RUM - start/stop session replay recording 0.0008 0.0012 +50.00%
Logs - log message 0.0151 0.0331 +119.21%
🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
RUM - add global context 26.64 KiB 25.69 KiB -971 B
RUM - add action 50.13 KiB 51.49 KiB +1.36 KiB
RUM - add timing 26.76 KiB 24.76 KiB -2.00 KiB
RUM - add error 56.21 KiB 54.02 KiB -2.19 KiB
RUM - start/stop session replay recording 25.57 KiB 24.64 KiB -957 B
RUM - start view 424.67 KiB 425.07 KiB +415 B
Logs - log message 47.45 KiB 107.43 KiB +59.97 KiB

🔗 RealWorld

@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Oct 23, 2025

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage
Patch Coverage: 75.00%
Overall Coverage: 77.27% (-0.03%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 31e5ac1 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@amortemousque amortemousque changed the title ⚗️MFE experiments ⚗️[MFE] Source code context event enrichment Jan 12, 2026
@amortemousque amortemousque force-pushed the bcaudan/mfe-build-plugin-support branch from 943c7a2 to 55969dd Compare January 12, 2026 14:38
@amortemousque amortemousque force-pushed the bcaudan/mfe-build-plugin-support branch from 2ced5e0 to 0e9289e Compare January 13, 2026 13:28
@bcaudan bcaudan marked this pull request as ready for review January 14, 2026 09:03
@bcaudan bcaudan requested a review from a team as a code owner January 14, 2026 09:03
Comment on lines 20 to 27
type DeepReadonly<T> = {
readonly [K in keyof T]: DeepReadonly<T[K]>
}

export interface AssembleHookParams {
readonly eventType: RumEvent['type']
rawRumEvent: DeepReadonly<RawRumEvent>
domainContext: DeepReadonly<RumEventDomainContext<RawRumEvent['type']>>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ question: ‏What is the intent with the DeepReadonly?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t want registered assemble hook callbacks to mutate the input, especially rawRumEvent. I avoided DeepReadonly<AssembleHookParams> because it forces casts for primitives (eventType, startTime, duration) throughout the code.

Example:
image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh ok, what about adding a comment with the code to make the intent more explicit?

import type { BrowserWindow } from './sourceCodeContext'
import { startSourceCodeContext } from './sourceCodeContext'

describe('sourceCodeContext', () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 suggestion: ‏It could be interesting to add e2e tests for this feature

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amortemousque amortemousque force-pushed the bcaudan/mfe-build-plugin-support branch from 14cfe74 to 4736888 Compare January 14, 2026 16:09
Copy link
Collaborator Author

@bcaudan bcaudan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

},
}

// because the evaluation the script in a different context than the page, resulting in unexpected stack traces
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 suggestion: ‏unclear to me what information we want to convey here and how it relates to create body 😕

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it’s a copy-paste from here. It means we use createBody instead of page.evaluate() because page.evaluate() messes up the stack trace and drops the URL. I’ll improve the comments.

Copy link
Contributor

@BeltranBulbarellaDD BeltranBulbarellaDD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@amortemousque amortemousque merged commit 7186051 into main Jan 16, 2026
21 checks passed
@amortemousque amortemousque deleted the bcaudan/mfe-build-plugin-support branch January 16, 2026 13:46
@github-actions github-actions bot locked and limited conversation to collaborators Jan 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants