Skip to content

✨ Add action and vital metadata to profiles#4148

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 11 commits into
mainfrom
teo.chaillou/RUM-14305-browser-add-action-and-vital-metadata-to-profiles
Mar 5, 2026
Merged

✨ Add action and vital metadata to profiles#4148
gh-worker-dd-mergequeue-cf854d[bot] merged 11 commits into
mainfrom
teo.chaillou/RUM-14305-browser-add-action-and-vital-metadata-to-profiles

Conversation

@MandragoreVR
Copy link
Copy Markdown
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
Copy Markdown

github-actions Bot commented Feb 6, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@cit-pr-commenter-54b7da
Copy link
Copy Markdown

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

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 173.96 KiB 174.16 KiB +200 B +0.11%
Rum Profiler 4.71 KiB 6.16 KiB +1.44 KiB +30.61%
Rum Recorder 24.88 KiB 24.88 KiB 0 B 0.00%
Logs 56.50 KiB 56.55 KiB +51 B +0.09%
Flagging 944 B 944 B 0 B 0.00%
Rum Slim 129.66 KiB 129.86 KiB +203 B +0.15%
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.0041 0.0048 +17.07%
RUM - add action 0.0134 0.0143 +6.72%
RUM - add error 0.0131 0.0124 -5.34%
RUM - add timing 0.0026 0.0029 +11.54%
RUM - start view 0.0126 0.0131 +3.97%
RUM - start/stop session replay recording 0.0008 0.0007 -12.50%
Logs - log message 0.014 0.0151 +7.86%
🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
RUM - add global context 25.60 KiB 27.31 KiB +1.72 KiB
RUM - add action 50.50 KiB 51.48 KiB +1007 B
RUM - add timing 27.38 KiB 27.17 KiB -216 B
RUM - add error 53.70 KiB 54.85 KiB +1.15 KiB
RUM - start/stop session replay recording 25.00 KiB 25.57 KiB +587 B
RUM - start view 450.23 KiB 448.59 KiB -1.64 KiB
Logs - log message 44.87 KiB 96.07 KiB +51.20 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
Copy Markdown

datadog-official Bot commented Feb 12, 2026

⚠️ Tests

Fix all issues with BitsAI or with Cursor

⚠️ Warnings

❄️ 2 New flaky tests detected

    actionHistory createActionHistory should add action information to history when RAW_RUM_EVENT_COLLECTED is triggered with action event from Edge 80.0.361.62 (Windows 10) (Datadog) (Fix with Cursor)

    vitalHistory createVitalHistory should add vital information to history when RAW_RUM_EVENT_COLLECTED is triggered with vital event from Edge 80.0.361.62 (Windows 10) (Datadog) (Fix with Cursor)

ℹ️ Info

🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 87.10%
Overall Coverage: 77.25% (+0.07%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 65a4937 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or 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 2 times, most recently from 5059362 to ac62ddd Compare February 18, 2026 17:14
@MandragoreVR MandragoreVR marked this pull request as ready for review February 18, 2026 17:28
Copy link
Copy Markdown
Collaborator

@thomasbertet thomasbertet left a comment

Choose a reason for hiding this comment

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

Looks good to me!

I believe we could have a more generic history combining all of the profiler's tracked events in one place, it would be slightly less code.

{
id: vitalStart.id,
startClocks: vitalStart.startClocks,
duration: 0 as Duration,
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.

I wonder if we should have another value for "non-stopped" events 🤔
Relying on 0 seems like it could be error prone and the BE that process should be aware 0 means "not stopped".
Maybe just undefined would work instead ? WDYT ?

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.

Good question... could we maybe settle for something like -1, though, to not have to re-do a rum-events-format PR to allow undefined here?

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.

Yes, but we will need to adjust the logic, I kinda forgot about this when I did the BE logic : https://github.com/DataDog/profiling-backend/pull/7969/changes#diff-fe24f465d52fe19d3a52bfd86ac3eaa5e441e710eca6bb9c26a14cac5ce169e4R339-R346

You can see I'm just using the duration field without taking into account if the duration is 0 or undefined.
Let's have -1 as signal for unfinished events. I'll prepare the BE to support that value.

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.

Actually maybe that's cleaner if that's undefined, even if we have to do another PR for the format, WDYT ?

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.

Works for me, I just updated!

@MandragoreVR MandragoreVR force-pushed the teo.chaillou/RUM-14305-browser-add-action-and-vital-metadata-to-profiles branch from ade4eac to 65b9912 Compare February 23, 2026 15:56
@MandragoreVR
Copy link
Copy Markdown
Collaborator Author

/to-staging

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 Bot commented Feb 23, 2026

View all feedbacks in Devflow UI.

2026-02-23 16:01:46 UTC ℹ️ Start processing command /to-staging


2026-02-23 16:01:53 UTC ℹ️ Branch Integration: starting soon, merge expected in approximately 14m (p90)

Commit 65b99121e9 will soon be integrated into staging-09.


2026-02-23 16:16:03 UTC ℹ️ Branch Integration: this commit was successfully integrated

Commit 65b99121e9 has been merged into staging-09 in merge commit 848b6b79d7.

Check out the triggered DDCI request.

If you need to revert this integration, you can use the following command: /code revert-integration -b staging-09

gh-worker-dd-mergequeue-cf854d Bot added a commit that referenced this pull request Feb 23, 2026
…a-to-profiles (#4148) into staging-09

Integrated commit sha: 65b9912

Co-authored-by: MandragoreVR <teo.chaillou@datadoghq.com>
@MandragoreVR MandragoreVR force-pushed the teo.chaillou/RUM-14305-browser-add-action-and-vital-metadata-to-profiles branch from 65b9912 to a68787a Compare February 24, 2026 09:32
@MandragoreVR
Copy link
Copy Markdown
Collaborator Author

/to-staging

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 Bot commented Feb 24, 2026

View all feedbacks in Devflow UI.

2026-02-24 09:32:53 UTC ℹ️ Start processing command /to-staging


2026-02-24 09:33:01 UTC ℹ️ Branch Integration: starting soon, merge expected in approximately 14m (p90)

Commit a68787a74c will soon be integrated into staging-09.


2026-02-24 09:46:05 UTC ℹ️ Branch Integration: this commit was successfully integrated

Commit a68787a74c has been merged into staging-09 in merge commit 661ba0a622.

Check out the triggered DDCI request.

If you need to revert this integration, you can use the following command: /code revert-integration -b staging-09

@MandragoreVR MandragoreVR force-pushed the teo.chaillou/RUM-14305-browser-add-action-and-vital-metadata-to-profiles branch from a68787a to 5e88cac Compare February 24, 2026 09:44
@MandragoreVR
Copy link
Copy Markdown
Collaborator Author

/to-staging -c

gh-worker-dd-mergequeue-cf854d Bot added a commit that referenced this pull request Feb 24, 2026
…a-to-profiles (#4148) into staging-09

Integrated commit sha: a68787a

Co-authored-by: MandragoreVR <teo.chaillou@datadoghq.com>
@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-02-24 09:45:39 UTC ℹ️ Start processing command /to-staging -c
If you need support, contact us on Slack #devflow!


2026-02-24 09:45:42 UTCDevflow: /to-staging -c

Cannot cancel integration of into staging-09:

This merge request was already processed and can't be unqueued anymore.

To get help about command usage, write /to-staging --help

If you need support, contact us on Slack #devflow with those details!


lifeCycle.subscribe(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, ({ rawRumEvent, startClocks, duration }) => {
if (rawRumEvent.type === 'action') {
const durationForEntry = duration ?? (0 as Duration)
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.

You can use duration! like we do in longTaskHistory

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 thing is that the duration is not always defined here since we can have punctual actions (or actions that are still ongoing) that don't have a duration. In these cases, we do need to default to 0 for the close method of the history, but we keep the undefined duration for the profiling metadata (which is not perfectly reflected, I will update that)

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.

Oh yes, my bad :)

.add(
{
id: rawRumEvent.action.id,
label: '',
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.

❓ question: ‏Is it expected not to have a label? Shouldn't it be the action name?

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 issue here is that actions' names might be redacted by the customers in beforeSend, and we currently have no way of knowing this (or at least no easy way). After talking about this with @thomasbertet, we decided that we would be fine without the action names, but I preferred leaving the field as an empty string here instead of removing it because we will still try to add it later!

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.

I see. We usually remove unnecessary attributes to avoid confusion. Would it be too much work to remove it?

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.

Well I was planning to try a follow-up to see if can get the action name in some cases when it's not redacted. Is that okay if I remove it later, only if my follow-up doesn't work?

(Otherwise, I wouldn't say it's too much work, just that we need to do a PR on rum-events-format to remove it, and probably on profiling-backend as well since it expects a label I think)

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.

Removing it would also need a BE PR to make it optional. Let's keep it for now :)

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.

I’m not convinced by this decision, but at least add a comment explaining why it’s empty ;)

Comment thread packages/rum/src/domain/profiling/actionHistory.ts Outdated
Comment thread packages/rum-core/src/domain/action/trackManualActions.ts
Comment thread packages/rum-core/src/domain/vital/vitalCollection.ts Outdated
Comment thread packages/rum-core/src/domain/vital/vitalCollection.ts Outdated
Comment thread packages/rum-core/src/domain/vital/vitalCollection.ts Outdated
Comment thread packages/rum-core/src/domain/action/trackManualActions.ts
.add(
{
id: rawRumEvent.action.id,
label: '',
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.

I see. We usually remove unnecessary attributes to avoid confusion. Would it be too much work to remove it?


lifeCycle.subscribe(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, ({ rawRumEvent, startClocks, duration }) => {
if (rawRumEvent.type === 'action') {
const durationForEntry = duration ?? (0 as Duration)
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.

Oh yes, my bad :)

@thomas-lebeau thomas-lebeau changed the title [Profiling] Add action and vital metadata to profiles ✨ Add action and vital metadata to profiles Mar 3, 2026
@MandragoreVR MandragoreVR force-pushed the teo.chaillou/RUM-14305-browser-add-action-and-vital-metadata-to-profiles branch 2 times, most recently from 430f58a to 2049f75 Compare March 3, 2026 16:03
@MandragoreVR MandragoreVR force-pushed the teo.chaillou/RUM-14305-browser-add-action-and-vital-metadata-to-profiles branch from 43c6247 to 65a4937 Compare March 5, 2026 09:51
@MandragoreVR
Copy link
Copy Markdown
Collaborator Author

@amortemousque I've just rebased as I had merge conflicts, but you can look only at this commit following our discussion!

Also, I've just created a task for the follow-up on preStart

@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit bf810ea into main Mar 5, 2026
22 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the teo.chaillou/RUM-14305-browser-add-action-and-vital-metadata-to-profiles branch March 5, 2026 13:49
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants