Skip to content

RUM-15454: Add Profiler status in RUM debug widget#3335

Merged
ambushwork merged 1 commit into
feature/continuous-profilingfrom
yl/profiling/add-debug-widget-indicator
Apr 3, 2026
Merged

RUM-15454: Add Profiler status in RUM debug widget#3335
ambushwork merged 1 commit into
feature/continuous-profilingfrom
yl/profiling/add-debug-widget-indicator

Conversation

@ambushwork

Copy link
Copy Markdown
Member

What does this PR do?

  • Add profiler status indicator into RUM debug widget by reading Profiling context
  • Fix a minor bug that when continuous profiling active window starts, the feature context is not updated.

Motivation

It's convenient for debugging continuous profiling

Demo

Screenshot 2026-04-03 at 14 52 23

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/add-debug-widget-indicator branch from 12cceb8 to db93569 Compare April 3, 2026 13:19
@ambushwork
ambushwork marked this pull request as ready for review April 3, 2026 13:20
@ambushwork
ambushwork requested review from a team as code owners April 3, 2026 13: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: db935697f8

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

@datadog-datadog-prod-us1

This comment has been minimized.

@codecov-commenter

codecov-commenter commented Apr 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 15.00000% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.53%. Comparing base (03d468b) to head (91e00d2).

Files with missing lines Patch % Lines
...roid/insights/internal/DefaultInsightsCollector.kt 0.00% 8 Missing ⚠️
...nsights/internal/overlay/DefaultInsightsOverlay.kt 0.00% 8 Missing ⚠️
...profiling/internal/ContinuousProfilingScheduler.kt 50.00% 1 Missing ⚠️
Additional details and impacted files
@@                      Coverage Diff                      @@
##           feature/continuous-profiling    #3335   +/-   ##
=============================================================
  Coverage                         71.53%   71.53%           
=============================================================
  Files                               948      948           
  Lines                             35072    35092   +20     
  Branches                           5945     5950    +5     
=============================================================
+ Hits                              25087    25103   +16     
- Misses                             8300     8312   +12     
+ Partials                           1685     1677    -8     
Files with missing lines Coverage Δ
...dog/android/profiling/internal/ProfilingFeature.kt 75.53% <ø> (ø)
...lin/com/datadog/android/rum/internal/RumFeature.kt 92.69% <100.00%> (-0.20%) ⬇️
...profiling/internal/ContinuousProfilingScheduler.kt 96.00% <50.00%> (-1.26%) ⬇️
...roid/insights/internal/DefaultInsightsCollector.kt 69.14% <0.00%> (-7.58%) ⬇️
...nsights/internal/overlay/DefaultInsightsOverlay.kt 0.00% <0.00%> (ø)

... and 34 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 force-pushed the yl/profiling/add-debug-widget-indicator branch 2 times, most recently from 4061876 to 4e9e635 Compare April 3, 2026 14:08
// Set the profiling flag in SharedPreferences to profile for the next app launch
ProfilingStorage.addProfilingFlag(appContext, sdkCore.name)
sdkCore.setEventReceiver(name, this)
// TODO RUM-13678: we need to update context from the actual profiler start call, not from here

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.

probably the comment still makes sense?

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.

This is outdated so I decide to remove it:

  • the profiling status is already updated both in ContinuousProfilingScheduler when it starts, also updated when the callback is called as described in TODO
  • but an update is still needed here for app-launch profiling since the moment when app-launch profiling is started, no context is available for updating, so we need to fetch the profiler status once we initialize the Profiling feature (this is the earliest moment that we can).

override fun onContextUpdate(featureName: String, context: Map<String, Any?>) {
if (featureName == Feature.PROFILING_FEATURE_NAME) {
val running = context[PROFILER_IS_RUNNING] as? Boolean ?: false
handler.post {

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 like the common approach in this class is to call withListenersUpdate, but having more fine-grained approach doesn't hurt anyway

}

override fun bindSdkCore(sdkCore: FeatureSdkCore) {
sdkCore.setContextUpdateReceiver(this)

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.

should we unsubscribe at some point?

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.

good point, fixed with new unbindSdkCore function

internal const val ONE_SECOND_NS = 1_000_000_000L

// Contract key; must match ProfilingFeature.PROFILER_IS_RUNNING in dd-sdk-android-profiling.
private const val PROFILER_IS_RUNNING = "profiler_is_running"

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.

for the future: maybe we can move it to the -internal module to share though

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.

yes, I wanted to do that but it involves too many places, so I decided to address it in another PR.

@ambushwork
ambushwork force-pushed the yl/profiling/add-debug-widget-indicator branch from 4e9e635 to 91e00d2 Compare April 3, 2026 14:49
@ambushwork
ambushwork merged commit 14ab1bc into feature/continuous-profiling Apr 3, 2026
27 checks passed
@ambushwork
ambushwork deleted the yl/profiling/add-debug-widget-indicator branch April 3, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants