Skip to content

RUM-15321: Continuous profiling writes are gated on pending RUM events#3310

Merged
ambushwork merged 1 commit into
feature/continuous-profilingfrom
yl/profiling/forward-rum-events-to-scheduler
Apr 3, 2026
Merged

RUM-15321: Continuous profiling writes are gated on pending RUM events#3310
ambushwork merged 1 commit into
feature/continuous-profilingfrom
yl/profiling/forward-rum-events-to-scheduler

Conversation

@ambushwork

@ambushwork ambushwork commented Apr 1, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Long task events and ANR Error events are forwarded to ContinuousProfilingScheduler when they are received by ProfilingFeature. Before we try to write the events for continuous profiling, we check if there are pending RUM events, this respects the fact that continuous profiling result should only be uploaded when there are crucial RUM events during the profiling.

Note: ContinuousProfilingScheduler only accepts the RUM events when the active window is open (profiler is running), otherwise the events will be dropped since they are not happening during the profiling window.

Motivation

RUM-15321

Additional Notes

Anything else we should know when reviewing?

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@ambushwork
ambushwork force-pushed the yl/profiling/forward-rum-events-to-scheduler branch 2 times, most recently from e56483e to 48af4ae Compare April 1, 2026 09:56
@datadog-datadog-prod-us1

This comment has been minimized.

@ambushwork
ambushwork force-pushed the yl/profiling/forward-rum-events-to-scheduler branch from 48af4ae to 3b707c8 Compare April 1, 2026 10:42
@codecov-commenter

codecov-commenter commented Apr 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.80488% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.56%. Comparing base (5ee4826) to head (590883f).

Files with missing lines Patch % Lines
...dog/android/profiling/internal/ProfilingFeature.kt 79.17% 0 Missing and 5 partials ⚠️
Additional details and impacted files
@@                       Coverage Diff                        @@
##           feature/continuous-profiling    #3310      +/-   ##
================================================================
+ Coverage                         71.50%   71.56%   +0.06%     
================================================================
  Files                               948      948              
  Lines                             35039    35072      +33     
  Branches                           5937     5945       +8     
================================================================
+ Hits                              25052    25096      +44     
+ Misses                             8313     8295      -18     
- Partials                           1674     1681       +7     
Files with missing lines Coverage Δ
...profiling/internal/ContinuousProfilingScheduler.kt 97.26% <100.00%> (+2.62%) ⬆️
.../android/profiling/internal/ProfilingDataWriter.kt 92.75% <ø> (+2.90%) ⬆️
...dog/android/profiling/internal/ProfilingFeature.kt 75.53% <79.17%> (+10.15%) ⬆️

... and 36 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ambushwork
ambushwork marked this pull request as ready for review April 1, 2026 11:20
@ambushwork
ambushwork requested review from a team as code owners April 1, 2026 11:20

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3b707c8843

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@mariusc83 mariusc83 closed this Apr 2, 2026
@0xnm 0xnm reopened this Apr 2, 2026
@ambushwork
ambushwork force-pushed the yl/profiling/forward-rum-events-to-scheduler branch 2 times, most recently from 2067c2a to 0587586 Compare April 2, 2026 11:58
kikoveiga
kikoveiga previously approved these changes Apr 2, 2026

override fun write(
profilingResult: PerfettoResult,
rumContext: ProfilingRumContext,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think it should be a single ProfilingRumContext, it should be the aggregation here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

removed.

Comment on lines +380 to +388
testedFeature = ProfilingFeature(
mockSdkCore,
ProfilingConfiguration(
customEndpointUrl = null,
applicationLaunchSampleRate = 100f,
continuousSampleRate = 100f
),
mockProfiler
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

shouldn't we pull this to the common setup method?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

testedFeature needs to be initialized with a full sample rate configuration in some tests, I added a fakeAllSampledConfiguration to reuse.

return this
}

fun hasLongTaskIds(expected: List<String>?): ProfileEventAssert {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

seems it is not used anywhere so far? is it supposed to be used in this PR?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it belongs to my next PR, it's a miss when splitting, removed.

Comment on lines +369 to +370
assertThat(testedScheduler.pendingLongTasks).isEqualTo(listOf(fakeRumLongTaskEvent))
assertThat(testedScheduler.pendingAnrEvents).isEqualTo(listOf(fakeRumAnrEvent))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

tip: alternatively containsOnly can be used to avoid extra listOf call

Suggested change
assertThat(testedScheduler.pendingLongTasks).isEqualTo(listOf(fakeRumLongTaskEvent))
assertThat(testedScheduler.pendingAnrEvents).isEqualTo(listOf(fakeRumAnrEvent))
assertThat(testedScheduler.pendingLongTasks).containsOnly(fakeRumLongTaskEvent)
assertThat(testedScheduler.pendingAnrEvents).containsOnly(fakeRumAnrEvent)

@ambushwork
ambushwork force-pushed the yl/profiling/forward-rum-events-to-scheduler branch from 0587586 to 590883f Compare April 3, 2026 09:39
@ambushwork
ambushwork requested review from 0xnm and kikoveiga April 3, 2026 09:42
@ambushwork
ambushwork merged commit 03d468b into feature/continuous-profiling Apr 3, 2026
26 checks passed
@ambushwork
ambushwork deleted the yl/profiling/forward-rum-events-to-scheduler branch April 3, 2026 11:01
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.

5 participants