Skip to content

🐛 [Profiler] Fix empty session ID & quota check on renew#4766

Merged
thomasbertet merged 4 commits into
mainfrom
thomas.bertet/PROF-15036-session-id-empty
Jun 15, 2026
Merged

🐛 [Profiler] Fix empty session ID & quota check on renew#4766
thomasbertet merged 4 commits into
mainfrom
thomas.bertet/PROF-15036-session-id-empty

Conversation

@thomasbertet

@thomasbertet thomasbertet commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Motivation

Profiles were being sent without a session ID:

  • The session ID was resolved at collection time via findTrackedSession(startTime), but the session history may no longer contain the entry by then, resulting in an empty session ID in the profile payload.

Quotas were not enforced on renewal:

  • On session renewal, the profiler restarted without re-checking whether the new session passes the profiling sampling rate, causing profiling to run for sessions that should not be sampled.

Relates to PROF-15036.

Changes

  • Capture session ID at instance start time: The session ID is now stored on RumProfilerRunningInstance when the profiler instance starts, and passed directly to handleProfilerTrace instead of being looked up by start time at collection.
  • Re-check sampling on session renewal: The SESSION_RENEWED handler now validates the new session against isSampled(newSession.id, correctedChildSampleRate(...)) before restarting the profiler.

Test instructions

Unit test added: should not restart profiling on session renewal when new session is not sampled for profiling in profiler.spec.ts.

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

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jun 11, 2026

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 172.46 KiB 172.46 KiB 0 B 0.00%
Rum Profiler 7.88 KiB 8.02 KiB +139 B +1.72%
Rum Recorder 21.23 KiB 21.23 KiB 0 B 0.00%
Logs 54.88 KiB 54.88 KiB 0 B 0.00%
Rum Slim 130.18 KiB 130.18 KiB 0 B 0.00%
Worker 22.96 KiB 22.96 KiB 0 B 0.00%

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Jun 11, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 75.00%
Overall Coverage: 76.84% (-0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 02dc778 | Docs | Datadog PR Page | Give us feedback!

@thomasbertet

Copy link
Copy Markdown
Collaborator Author

/to-staging

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jun 11, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-06-11 13:16:57 UTC ℹ️ Start processing command /to-staging


2026-06-11 13:17:04 UTC ℹ️ Branch Integration: starting soon, merge expected in approximately 17m (p90)

Commit 3fbc921b4d will soon be integrated into staging-24.


2026-06-11 13:33:57 UTC ℹ️ Branch Integration: this commit was successfully integrated

Commit 3fbc921b4d has been merged into staging-24 in merge commit f71db4ddd8.

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

gh-worker-dd-mergequeue-cf854d Bot added a commit that referenced this pull request Jun 11, 2026
…ing-24

Integrated commit sha: 3fbc921

Co-authored-by: thomasbertet <thomas.bertet@datadoghq.com>
@thomasbertet thomasbertet force-pushed the thomas.bertet/PROF-15036-session-id-empty branch from 3fbc921 to 37bdc50 Compare June 11, 2026 14:12
… profiler

The SESSION_RENEWED handler was restarting the profiler without validating
whether the new session passes the profiling sampling check, causing profiling
to run for sessions that should not be sampled.
findTrackedSession(startTime) was called at collection time to resolve
the session ID, but the session history may no longer contain the entry
by then, resulting in an empty session ID in the profile payload. The
session ID is now captured when the profiler instance starts.
…ce start time

The previous test checked that findTrackedSession was called with a start
time argument, which matched the old implementation. The test now verifies
the actual behavior: the session ID captured when the profiler instance
starts is used in the payload even if the session changes before collection.
@thomasbertet thomasbertet force-pushed the thomas.bertet/PROF-15036-session-id-empty branch from cd3178c to 02dc778 Compare June 12, 2026 08:38
@thomasbertet thomasbertet changed the title 🐛 [PROF-15036] Fix profiler running with empty session ID 🐛 [Profiler] Fix empty session ID & quota check on renew Jun 12, 2026
@thomasbertet

Copy link
Copy Markdown
Collaborator Author

/code revert-integration -b staging-24

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jun 12, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-06-12 08:59:11 UTC ℹ️ Start processing command /code revert-integration -b staging-24


2026-06-12 08:59:19 UTC ℹ️ Devflow:

Revert commits generated, trying to integrate them into staging-24...


2026-06-12 08:59:23 UTC ℹ️ Branch Integration: starting soon, merge expected in approximately 17m (p90)

Commit c0a465e8a3 will soon be integrated into staging-24.


2026-06-12 09:17:15 UTC ℹ️ Branch Integration: this commit was successfully integrated

Commit c0a465e8a3 has been merged into staging-24 in merge commit 53bd4cffba.

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


2026-06-12 09:17:16 UTC ℹ️ Devflow: /code revert-integration -b staging-24

The changes from f71db4ddd8 have been successfully reverted from staging-24.

gh-worker-dd-mergequeue-cf854d Bot added a commit that referenced this pull request Jun 12, 2026
…ing-24

Integrated commit sha: c0a465e

Co-authored-by: gh-worker-dd-devflow-36fce6[bot] <244854925+gh-worker-dd-devflow-36fce6[bot]@users.noreply.github.com>
Co-authored-by: thomas.bertet <thomas.bertet@datadoghq.com>
@thomasbertet thomasbertet marked this pull request as ready for review June 12, 2026 14:04
@thomasbertet thomasbertet requested a review from a team as a code owner June 12, 2026 14:04
@thomasbertet thomasbertet merged commit 4d099f1 into main Jun 15, 2026
33 checks passed
@thomasbertet thomasbertet deleted the thomas.bertet/PROF-15036-session-id-empty branch June 15, 2026 14:08
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 15, 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.

2 participants