Skip to content

refactor(rum): Simplify profiler cleanup and stop transitions - #5298

Draft
amortemousque wants to merge 4 commits into
mainfrom
amortemousque/simplify-profiler-cleanup
Draft

amortemousque wants to merge 4 commits into
mainfrom
amortemousque/simplify-profiler-cleanup

Conversation

@amortemousque

Copy link
Copy Markdown
Collaborator

Motivation

Profiler shutdown duplicates timer cleanup, listener removal, and trace disposal. The nested stop-state checks also make it harder to follow which stop reasons are preserved.

Changes

  • Centralize running-profiler cleanup in stopRunningProfiler, with a discard option for quota denials.
  • Flatten the stopped-state guard while preserving explicit user stops and synchronous state transitions.
  • AI-assisted internal refactor; no intended public behavior change.

Test instructions

Run the existing profiler suite, which covers stop/start, visibility changes, session renewal, and quota checks:

yarn test:unit packages/browser-rum/src/domain/profiling/datadogProfiler.spec.ts
yarn prettier --check packages/browser-rum/src/domain/profiling/datadogProfiler.ts
yarn eslint packages/browser-rum/src/domain/profiling/datadogProfiler.ts

Verified locally: all 39 tests pass; formatting and lint pass. No manual sandbox or staging test was performed.

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change. Existing profiler coverage reused.
  • Added e2e/integration tests for this change. Not applicable to this internal refactor.
  • Updated documentation and/or relevant AGENTS.md file. Not applicable.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum Salesforce 194.51 KiB 195.51 KiB +1.01 KiB +0.52% ✅
Rum 194.48 KiB 195.49 KiB +1.01 KiB +0.52% ✅
Rum Salesforce Profiler 8.10 KiB 7.24 KiB -885 B -10.67% ✅
Rum Profiler 8.10 KiB 7.24 KiB -885 B -10.67% ✅
Rum Salesforce Recorder 32.80 KiB 32.80 KiB 0 B 0.00% ✅
Rum Recorder 32.80 KiB 32.80 KiB 0 B 0.00% ✅
Logs 60.25 KiB 60.25 KiB 0 B 0.00% ✅
Rum Slim 149.87 KiB 149.87 KiB 0 B 0.00% ✅
Worker 24.23 KiB 24.23 KiB 0 B 0.00% ✅
Rum Shopify 226.03 KiB 227.04 KiB +1.01 KiB +0.45% ✅
Rum Shopify Profiler 8.10 KiB 7.24 KiB -885 B -10.67% ✅
Rum Shopify Recorder 4.85 KiB 4.85 KiB 0 B 0.00% ✅
Early Collection 309 B 309 B 0 B 0.00% ✅

@datadog-datadog-us1-prod

datadog-datadog-us1-prod Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 79.69%
• Overall Coverage: 78.13% (+0.06%)

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

@amortemousque
amortemousque force-pushed the amortemousque/simplify-profiler-cleanup branch from 155e570 to a1f4eca Compare November 23, 2026 16:32
@thomas-lebeau thomas-lebeau changed the title ♻️ Simplify profiler cleanup and stop transitions refactor(rum): Simplify profiler cleanup and stop transitions Nov 24, 2026
@amortemousque
amortemousque force-pushed the amortemousque/simplify-profiler-cleanup branch from a1f4eca to 1dc30fa Compare November 25, 2026 10:52

This branch has not been deployed

No deployments
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