Skip to content

♻️ Simplify profiler cleanup and stop transitions - #5298

Draft
amortemousque wants to merge 1 commit into
mainfrom
amortemousque/simplify-profiler-cleanup
Draft

amortemousque wants to merge 1 commit 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

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum Salesforce 192.85 KiB 192.85 KiB 0 B 0.00% ✅
Rum 192.82 KiB 192.82 KiB 0 B 0.00% ✅
Rum Salesforce Profiler 8.01 KiB 7.87 KiB -140 B -1.71% ✅
Rum Profiler 8.01 KiB 7.87 KiB -140 B -1.71% ✅
Rum Salesforce Recorder 32.62 KiB 32.62 KiB 0 B 0.00% ✅
Rum Recorder 32.62 KiB 32.62 KiB 0 B 0.00% ✅
Logs 60.25 KiB 60.25 KiB 0 B 0.00% ✅
Rum Slim 148.67 KiB 148.67 KiB 0 B 0.00% ✅
Worker 24.23 KiB 24.23 KiB 0 B 0.00% ✅
Rum Shopify 224.18 KiB 224.18 KiB 0 B 0.00% ✅
Rum Shopify Profiler 8.00 KiB 7.87 KiB -140 B -1.71% ✅
Rum Shopify Recorder 4.85 KiB 4.85 KiB 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: 62.50%
• Overall Coverage: 77.82% (-0.09%)

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

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