Skip to content

RUM-13627: Add sample rate for App launch profiling#3109

Merged
0xnm merged 1 commit into
feature/perfetto-profilingfrom
yl/profiling/sampling-rate
Jan 13, 2026
Merged

RUM-13627: Add sample rate for App launch profiling#3109
0xnm merged 1 commit into
feature/perfetto-profilingfrom
yl/profiling/sampling-rate

Conversation

@ambushwork

Copy link
Copy Markdown
Member

What does this PR do?

A brief description of the change being made with this pull request.

Motivation

What inspired you to submit this pull request?

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/sampling-rate branch 2 times, most recently from a57c937 to d7e1cc1 Compare January 7, 2026 14:23
@datadog-official

datadog-official Bot commented Jan 7, 2026

Copy link
Copy Markdown

🎯 Code Coverage
Patch Coverage: 59.38%
Overall Coverage: 65.93%

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: df55a77 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@codecov-commenter

codecov-commenter commented Jan 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 59.25926% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.84%. Comparing base (4b65d7d) to head (df55a77).
⚠️ Report is 201 commits behind head on feature/perfetto-profiling.

Files with missing lines Patch % Lines
...og/android/profiling/DdProfilingContentProvider.kt 0.00% 5 Missing ⚠️
.../android/internal/data/SharedPreferencesStorage.kt 0.00% 4 Missing ⚠️
...atadog/android/internal/data/PreferencesStorage.kt 0.00% 1 Missing ⚠️
...dog/android/profiling/internal/ProfilingStorage.kt 75.00% 1 Missing ⚠️
Additional details and impacted files
@@                      Coverage Diff                       @@
##           feature/perfetto-profiling    #3109      +/-   ##
==============================================================
- Coverage                       71.52%   70.84%   -0.68%     
==============================================================
  Files                             894      906      +12     
  Lines                           32838    33347     +509     
  Branches                         5516     5586      +70     
==============================================================
+ Hits                            23486    23622     +136     
- Misses                           7800     8167     +367     
- Partials                         1552     1558       +6     
Files with missing lines Coverage Δ
...atadog/android/profiling/ProfilingConfiguration.kt 100.00% <100.00%> (ø)
...dog/android/profiling/internal/ProfilingFeature.kt 68.63% <100.00%> (+6.13%) ⬆️
...atadog/android/internal/data/PreferencesStorage.kt 0.00% <0.00%> (ø)
...dog/android/profiling/internal/ProfilingStorage.kt 96.00% <75.00%> (-4.00%) ⬇️
.../android/internal/data/SharedPreferencesStorage.kt 86.21% <0.00%> (-13.79%) ⬇️
...og/android/profiling/DdProfilingContentProvider.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 marked this pull request as ready for review January 7, 2026 15:07
@ambushwork
ambushwork requested a review from a team as a code owner January 7, 2026 15:07

@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: d7e1cc1214

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


@RequiresApi(Build.VERSION_CODES.VANILLA_ICE_CREAM)
private fun sampleProfiling(context: Context, instanceNames: Set<String>) {
val sampleRate = ProfilingStorage.getSampleRate(context)

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.

Storing sample rate disconnected from the SDK instance it set creates the following problem: suppose there is instance A with sample rate 10%, and instance B with sample rate 40%. Instance B is initialized after instance A, so the sample rate recorded will be 40%.

It means that instance A will have 40% sample rate, increasing the billing and exploding the profile volume for this org.

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.

I updated the logic of persisting the sample rate, now we set sample rate of configuration only if the sample rate is absent in sp or the old value is bigger than the new value.

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.

But this new logic also means if user wants to set sampling rate higher, nothing will be done, isn't it?

@ambushwork ambushwork Jan 9, 2026

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.

Sample rate is also an one-time flag, once it's consumed, it will be removed, see here. then user can set another sample rate, lower or higher. one thing may miss here is that, if the session is sampled out, then set a lower sample rate will be ignored

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.

I updated the logic when the profiling is sampled out, the sample rate will be removed


companion object {

private const val DEFAULT_SAMPLE_RATE = 100f

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 100% by default.

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.

For me 100f means let rate limiter handle the sampling, which is kind of OK, what value do you suggest?

@ambushwork
ambushwork force-pushed the yl/profiling/sampling-rate branch 3 times, most recently from b8494ea to 1b81f8d Compare January 8, 2026 15:34
@ambushwork
ambushwork requested a review from 0xnm January 8, 2026 16:03
@ambushwork
ambushwork force-pushed the yl/profiling/sampling-rate branch from 1b81f8d to e699abe Compare January 8, 2026 16:32
@ambushwork
ambushwork force-pushed the yl/profiling/sampling-rate branch from e699abe to df55a77 Compare January 9, 2026 14:32
@0xnm
0xnm merged commit 118dea8 into feature/perfetto-profiling Jan 13, 2026
26 checks passed
@0xnm
0xnm deleted the yl/profiling/sampling-rate branch January 13, 2026 09:20
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.

3 participants