Skip to content

[Profiling] Add action and vital metadata to profiles#4148

Draft
MandragoreVR wants to merge 3 commits intomainfrom
teo.chaillou/RUM-14305-browser-add-action-and-vital-metadata-to-profiles
Draft

[Profiling] Add action and vital metadata to profiles#4148
MandragoreVR wants to merge 3 commits intomainfrom
teo.chaillou/RUM-14305-browser-add-action-and-vital-metadata-to-profiles

Conversation

@MandragoreVR
Copy link
Collaborator

@MandragoreVR MandragoreVR commented Feb 6, 2026

Motivation

To enable profiling aggregation on the backend for vitals and actions, we want to add vitals and actions data to the metadata of profiling events.

This PR adds these entries to the profiling events metadata.

Changes

  • Create a vitalHistory next to the profiler that catches vital events from the life cycle and stores them in the history
    • Vital events are currently only sent in the lifecycle when they end. However, one vital event might span over multiple profiles, so the profile where this vital event starts must be tagged with this vital event too.
      • This PR defines the id of duration vitals when they start instead of when they end, and adds a new lifecycle event to broadcast vitals when they start
      • Note: this will not cause issues if the vital doesn't end, because this is only used to tag profile events, so in the worst case, the id of this vital will not be used
  • Same thing for the actions: creation of an actionHistory
    • the id of the action was created on action start, but not returned by the event tracker, so I changed that to make the start method of the event tracker return the stored data
  • Update the build of a profile's attributes to add actions and vitals
    • update profiler's tests to make sure vitals and actions are collected

Test instructions

  • In the file sandbox/react-app/main.tsx, add:
profilingSampleRate: 100,
  site: 'datadoghq.com',
  service: 'sandbox-react-app',
  env: 'development',
  beforeSend: () => false,

to the SDK configuration, and add

  useEffect(() => {
    datadogRum.startDurationVital('test vital')

    const timeout = setTimeout(() => {
      datadogRum.stopDurationVital('test vital')
    }, 1000)

    return () => {
      clearTimeout(timeout)
    }
  }, [])

before the return of the Layout function to have a vital that will be displayed in the collected ones.

  • Run yarn dev and go to localhost:8080/react-app
  • Wait for a request to https://browser-intake-datadoghq.com/api/v2/profile in the network tab (profiles usually last one minute, so this might not come instantly, but you can also edit the constant collectIntervalMs in profiler.ts to make it faster)
  • Look at the payload, that contains two big objects.
    • The first one should contain the fields "action" and "vital", both with an object of the shape { "id": string[], "label": string[] }
    • The second one should contain the fields "action" and "vitals" with the following shape:
image

Checklist

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

@MandragoreVR MandragoreVR self-assigned this Feb 6, 2026
@github-actions
Copy link

github-actions bot commented Feb 6, 2026


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@cit-pr-commenter-54b7da
Copy link

cit-pr-commenter-54b7da bot commented Feb 6, 2026

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 169.43 KiB 170.03 KiB +610 B +0.35%
Rum Profiler 4.29 KiB 4.66 KiB +373 B +8.48%
Rum Recorder 24.54 KiB 24.54 KiB 0 B 0.00%
Logs 56.72 KiB 56.72 KiB 0 B 0.00%
Flagging 944 B 944 B 0 B 0.00%
Rum Slim 126.26 KiB 126.86 KiB +613 B +0.47%
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.0045 0.0043 -4.44%
RUM - add action 0.0142 0.0132 -7.04%
RUM - add error 0.0133 0.0142 +6.77%
RUM - add timing 0.0028 0.003 +7.14%
RUM - start view 0.0134 0.015 +11.94%
RUM - start/stop session replay recording 0.0007 0.0008 +14.29%
Logs - log message 0.0155 0.0163 +5.16%
🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
RUM - add global context 27.68 KiB 28.01 KiB +340 B
RUM - add action 51.86 KiB 62.57 KiB +10.71 KiB
RUM - add timing 26.47 KiB 27.03 KiB +566 B
RUM - add error 57.53 KiB 56.34 KiB -1.19 KiB
RUM - start/stop session replay recording 25.70 KiB 26.56 KiB +886 B
RUM - start view 453.18 KiB 452.37 KiB -835 B
Logs - log message 47.21 KiB 45.50 KiB -1.71 KiB

🔗 RealWorld

@MandragoreVR MandragoreVR force-pushed the teo.chaillou/RUM-14305-browser-add-action-and-vital-metadata-to-profiles branch 2 times, most recently from 59aa5b7 to f709051 Compare February 12, 2026 13:32
@MandragoreVR MandragoreVR marked this pull request as ready for review February 12, 2026 13:33
@MandragoreVR MandragoreVR requested a review from a team as a code owner February 12, 2026 13:33
@datadog-official
Copy link

datadog-official bot commented Feb 12, 2026

⚠️ Tests

Fix all issues with BitsAI or with Cursor

⚠️ Warnings

🧪 1 Test failed

preStartRum buffers API calls before starting RUM startDurationVital from Chrome Headless 139.0.0.0 (Linux 0.0.0) (Datadog) (Fix with Cursor)
TypeError: lifeCycle.notify is not a function
    at startDurationVital (/tmp/_karma_webpack_954064/commons.js:214964:13)
    at Object.startDurationVital (/tmp/_karma_webpack_954064/commons.js:119765:96)
    at UserContext.<anonymous> (/go/src/github.com/DataDog/browser-sdk/packages/rum-core/src/boot/preStartRum.spec.ts:658:16 <- /tmp/_karma_webpack_954064/commons.js:335538:22)
    at <Jasmine>

ℹ️ Info

❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 89.19%
Overall Coverage: 77.18% (+0.03%)

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

@MandragoreVR MandragoreVR marked this pull request as draft February 17, 2026 15:51
@MandragoreVR MandragoreVR force-pushed the teo.chaillou/RUM-14305-browser-add-action-and-vital-metadata-to-profiles branch from f709051 to 2d17fef Compare February 17, 2026 22:25
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