Skip to content

✨ [DEBUG-6251] Add a point-in-time RUM action on the first hit of EXIT probes - #5122

Merged
watson merged 1 commit into
mainfrom
watson/DEBUG-6251/rum-action-on-exit-probe-hit
Oct 8, 2026
Merged

watson merged 1 commit into
mainfrom
watson/DEBUG-6251/rum-action-on-exit-probe-hit

Conversation

@watson

@watson watson commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

DEBUG-6251: follow-up to #5107, which only created RUM custom actions for probes evaluated at function entry. EXIT probes were skipped because their condition is only known at exit, and the public RUM API can't backdate the start of an action. For now, EXIT probes get a point-in-time action at the function exit, so we can still find the RUM sessions in which they fired.

Changes

The first qualifying hit of an EXIT probe (one that passes sampling and its exit condition) now calls DD_RUM.addAction() at function exit:

 onEntry
   ENTRY probe → startAction(name, { actionKey: snapshotId, context: { probe, snapshot } })
 onReturn / onThrow
   ENTRY probe → stopAction(name, { actionKey: snapshotId, context: { outcome, error } })
+  EXIT probe, after the exit condition passes
+    → addAction(name, { debugger: { probe, snapshot, outcome, error } })
   queue snapshot (reuses the action's snapshot id)
  • Same action name (probe: <method> (<file>)) and the same final context as ENTRY probe actions, and the snapshot sent for that hit reuses the action's snapshot id.
  • Same rules as ENTRY probes: first qualifying hit per probe instance, the probe stays armed until DD_RUM is on the page, trackProbeHitsAsRumActions: false disables it, and RUM API failures can't break the instrumented function or prevent the snapshot.
  • Condition-evaluation errors and capture-expression timeouts (no snapshot sent) don't create an action.
  • README and trackProbeHitsAsRumActions JSDoc updated.

Worth a reviewer's eye (AI-assisted implementation):

  • No duration: addAction events have no action.loading_time at all, rather than loading_time: 0. Calling startAction/stopAction back to back would instead record a meaningless sub-millisecond duration.
  • Timestamp: the action's date is when addAction runs, after the exit condition, message and capture expressions are evaluated (bounded by the existing 10ms capture deadline). The snapshot's timestamp is taken just before the condition, so the two can differ slightly.
  • Telemetry: like startAction/stopAction in ✨ [DEBUG-6251] Start a RUM action on the first hit of each browser probe #5107, the public addAction records add-action usage telemetry. Avoiding that, and supporting real EXIT-probe durations, still needs an internal RUM API designed with the RUM team.

Test instructions

  1. yarn test:unit --spec 'packages/browser-debugger/src/**/*.spec.ts'. The old should not start an action for EXIT probes test is replaced by a RUM actions > for EXIT probes suite in api.spec.ts.
  2. yarn test:e2e test/e2e/scenario/debugger.scenario.ts -g "RUM action on the first hit". The new add a point-in-time RUM action on the first hit of an EXIT probe scenario calls an instrumented function twice with an EXIT probe, then checks that exactly one custom action is sent, with no loading_time, the matching snapshot id and outcome: 'return'.
  3. Manually, in an app with RUM + the debugger and the build plugin: set an EXIT log probe, trigger the function, and check the RUM explorer for @action.type:custom @context.debugger.probe.id:<probe id>.

Locally: 883/883 browser-debugger unit tests pass, and both RUM action E2E scenarios (ENTRY and EXIT) pass on Chromium.

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

🤖 Generated with Claude Code

…T probes

Probes evaluated at function exit previously didn't create a RUM custom
action, because the RUM API can't backdate the start of an action once
the EXIT condition is known. For now, the first qualifying hit of an EXIT
probe adds a point-in-time action at the function exit with
DD_RUM.addAction(), with the same name and context (probe, snapshot ID,
outcome and error type) as ENTRY probe actions.

Environment: Datadog workspace

Co-Authored-By: Claude Code Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Co-authored-by: Claude Code Claude Opus 5.5 <noreply@anthropic.com>
@watson
watson requested review from a team as code owners October 8, 2026 18:06
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-08T18:08:57.838344Z 8661004 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

✨ Unblock PR with BitsAI

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 1 Pipeline job failed

DataDog/browser-sdk | check-node-version — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 80.00%
• Overall Coverage: 77.17% (+0.01%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 8661004 | Docs | View more details | Give us feedback!

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum Salesforce N/A 185.67 KiB N/A N/A N/A
Rum 185.65 KiB 185.65 KiB 0 B 0.00% ✅
Rum-salesforce Profiler N/A 8.38 KiB N/A N/A N/A
Rum Profiler 8.38 KiB 8.38 KiB 0 B 0.00% ✅
Rum-salesforce Recorder N/A 31.94 KiB N/A N/A N/A
Rum Recorder 31.94 KiB 31.94 KiB 0 B 0.00% ✅
Logs 59.57 KiB 59.57 KiB 0 B 0.00% ✅
Rum Slim 143.65 KiB 143.65 KiB 0 B 0.00% ✅
Worker 22.96 KiB 22.96 KiB 0 B 0.00% ✅
Rum Shopify N/A 216.06 KiB N/A N/A N/A
Rum-shopify Profiler N/A 8.38 KiB N/A N/A N/A
Rum-shopify Recorder N/A 4.77 KiB N/A N/A N/A

@watson
watson merged commit 064b446 into main Oct 8, 2026
30 of 32 checks passed
@watson
watson deleted the watson/DEBUG-6251/rum-action-on-exit-probe-hit branch October 8, 2026 18:34
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 8, 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.

3 participants