Skip to content

✨ [RUM-16632] add profiling bridge mode support#4747

Open
bcaudan wants to merge 6 commits into
mainfrom
bcaudan/profiling-bridge-mode
Open

✨ [RUM-16632] add profiling bridge mode support#4747
bcaudan wants to merge 6 commits into
mainfrom
bcaudan/profiling-bridge-mode

Conversation

@bcaudan

@bcaudan bcaudan commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Motivation

Profiling data is always sent directly to the intake via HTTP. In Electron and WebView environments where the native SDK acts as a proxy through the bridge, profiling requests would use dummy session and application IDs, resulting in rejections at the intake.

Changes

  • Add BridgeCapability.PROFILES: route profiling through the bridge when the native SDK advertises it, disable profiling silently when a bridge is present without that capability
  • Refactor the profiler to be transport-agnostic: introduce an emitPayload callback so the profiler core no longer owns transport decisions
  • Add ProfilingPayload as a shared domain type (profile + trace) passed to both the bridge emitter and the FormData emitter
  • Session injection for the non-bridge path moves to formDataEmitter, keeping the bridge path session-free (the native SDK handles it)

Test instructions

Unit tests cover bridge mode routing, session injection, and sampling. E2E test covers the bridge path end-to-end using the mock bridge.

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

@cit-pr-commenter-54b7da

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

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 172.44 KiB 172.49 KiB +55 B +0.03%
Rum Profiler 7.88 KiB 8.06 KiB +179 B +2.22%
Rum Recorder 21.23 KiB 21.23 KiB 0 B 0.00%
Logs 54.86 KiB 54.86 KiB 0 B 0.00%
Rum Slim 130.17 KiB 130.17 KiB 0 B 0.00%
Worker 22.96 KiB 22.96 KiB 0 B 0.00%

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jun 8, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

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

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

@bcaudan bcaudan force-pushed the bcaudan/profiling-bridge-mode branch 5 times, most recently from 7823bb8 to 7bbd8e9 Compare June 8, 2026 14:56
@bcaudan bcaudan force-pushed the bcaudan/profiling-bridge-mode branch from 7bbd8e9 to d0e4767 Compare June 8, 2026 15:15
@bcaudan

bcaudan commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@bcaudan bcaudan marked this pull request as ready for review June 10, 2026 13:57
@bcaudan bcaudan requested a review from a team as a code owner June 10, 2026 13:57
Comment thread packages/browser-rum/src/boot/profilerApi.ts Outdated
}

export interface ProfilingPayload {
profile: BrowserProfileEvent

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

suggestion: call this property event to align the naming between transports?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The bridge "event" is actually the full payload:

{
  "eventType": "profile",
  "event": {
    "profile": { ...BrowserProfileEvent },
    "trace":   { ...BrowserProfilerTrace }
  }
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So, you do this to avoid the `event: { event: ... }?

I would still rename profile to event in the payload to avoid back-and-forth between namings:


const formPayload = { event: profile, 'wall-time.json': trace }

But that's a nitpick, you can ignore :)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

So, you do this to avoid the `event: { event: ... }?

Yeah, it felt a bit confusing

@thomasbertet thomasbertet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code LGTM.

Comment thread packages/browser-rum/src/domain/profiling/datadogProfiler.ts
bcaudan added 2 commits June 11, 2026 11:13
- remove createBridgeEmitter/createFormDataEmitter imports from profilerApi.ts (main bundle)
- createRumProfiler now calls canUseEventBridge() directly to select transport
- add transport selection tests in datadogProfiler.spec.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1afb4bc37b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/browser-rum/src/domain/profiling/datadogProfiler.ts
Comment thread packages/browser-rum/src/domain/profiling/datadogProfiler.ts
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.

4 participants