Skip to content

Update profiling telemetry with more data#3240

Merged
ambushwork merged 1 commit into
developfrom
yl/profiling/update-start-reasons
Mar 18, 2026
Merged

Update profiling telemetry with more data#3240
ambushwork merged 1 commit into
developfrom
yl/profiling/update-start-reasons

Conversation

@ambushwork

Copy link
Copy Markdown
Member

What does this PR do?

  • This PR updates the profiling telemetry format
    • Message from "[Mobile Metric] App Launch" to "[Mobile Metric] Profiling Session"
    • Add "start_reason" attribute: currently "application_launch", "rum_operation"/"continuous" in the future
    • Add "app_start_info" attribute for application launch profiling
  • Update DdProfilingContentProvider to be more testable
  • Add DdProfilingContentProvider Test

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/update-start-reasons branch 2 times, most recently from 4bf8abd to 2d710ed Compare March 6, 2026 14:42
@datadog-official

This comment has been minimized.

@ambushwork
ambushwork force-pushed the yl/profiling/update-start-reasons branch 2 times, most recently from 8fd82a9 to 6cc58e1 Compare March 6, 2026 15:41
@ambushwork ambushwork changed the title Upldate profiling telemetry with more data Update profiling telemetry with more data Mar 6, 2026
@codecov-commenter

codecov-commenter commented Mar 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.35849% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.57%. Comparing base (ba162fa) to head (77733bd).
⚠️ Report is 109 commits behind head on develop.

Files with missing lines Patch % Lines
...og/android/profiling/DdProfilingContentProvider.kt 61.90% 2 Missing and 6 partials ⚠️
...android/internal/system/BuildSdkVersionProvider.kt 0.00% 2 Missing ⚠️
...in/java/com/datadog/android/profiling/Profiling.kt 66.67% 1 Missing ⚠️
...dog/android/profiling/internal/ProfilingFeature.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3240      +/-   ##
===========================================
+ Coverage    71.49%   71.57%   +0.08%     
===========================================
  Files          934      935       +1     
  Lines        34628    34667      +39     
  Branches      5862     5865       +3     
===========================================
+ Hits         24755    24810      +55     
+ Misses        8231     8216      -15     
+ Partials      1642     1641       -1     
Files with missing lines Coverage Δ
...android/profiling/internal/ProfilingStartReason.kt 100.00% <100.00%> (ø)
...id/profiling/internal/perfetto/PerfettoProfiler.kt 91.59% <100.00%> (-1.18%) ⬇️
...in/java/com/datadog/android/profiling/Profiling.kt 85.00% <66.67%> (+3.18%) ⬆️
...dog/android/profiling/internal/ProfilingFeature.kt 66.04% <0.00%> (ø)
...android/internal/system/BuildSdkVersionProvider.kt 0.00% <0.00%> (ø)
...og/android/profiling/DdProfilingContentProvider.kt 51.61% <61.90%> (+51.61%) ⬆️

... and 35 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/update-start-reasons branch 3 times, most recently from 637833e to e4c1104 Compare March 9, 2026 13:14
@ambushwork
ambushwork marked this pull request as ready for review March 9, 2026 13:29
@ambushwork
ambushwork requested review from a team as code owners March 9, 2026 13:29

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

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

Comment on lines +93 to +97
sendProfilingEndTelemetry(
result = result,
duration = duration,
startReason = profilingStartReason,
appStartInfo = profilingAppStartInfo

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Snapshot telemetry metadata before clearing running state

This callback reads profilingStartReason/profilingAppStartInfo from mutable fields after runningInstances is reset to empty, which allows a new start() call to win the CAS and overwrite those fields before telemetry is logged for the finishing session. In back-to-back profiling sessions (for example once non-launch reasons are used), the first session can emit the wrong start_reason and app_start_info values. Capture these values in local variables before reopening runningInstances (or make them request-scoped) so telemetry stays tied to the correct run.

Useful? React with 👍 / 👎.

0xnm
0xnm previously approved these changes Mar 10, 2026

internal enum class ProfilingStartReason(val value: String) {

APPLICATION_LAUNCH("application_launch"),

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 it will just go away with having continuous profiling? Or you see continuous profiling which is started not at the application launch, but at some point later?

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 don't think so, app launch profiling will always be there from app launch to TTID, continuous profiling will not start immediately according to the RFC, we will probably add a jitter window.

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.

Which is probably just a complexity we bring? It is possible to start continuous profiling at the application launch and have this only, given that we label samples with Vital ID/Vital Name anyway.

It seems the only reason to have Application Launch profiling separate is a distinct sampling frequency. But anyway, having it this way brings a complexity if there is feature operation started before TTID.

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.

Imagine we always start continuous profiling at the application launch and we try to extend this first profiling to maximum duration (let's say 1 min due to the payload size limitation) and then cooldown for 5 minutes, then the events happen during 1min ~ 6min is very likely to be missed.

We can defer this discussion in the RFC, but currently since continuous is not implemented yet, I think it still make sense to keep it here.

Comment on lines +55 to +59
@Volatile
private var profilingStartReason: String = ""

@Volatile
private var profilingAppStartInfo: String? = null

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.

nit: it is better to use type-system at this point still, referencing enums and convert to String which is a generic type only when it is really needed, at the very last stage.

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.

updated profilingStartReason to enum type, added an UNKNOWN state in the enum as default.

"file_size" to 0L,
"stopped_reason" to "timeout"
"stopped_reason" to "timeout",
"app_start_info" to null

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.

nit: maybe app_start_origin would make a bit more 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.

here I follow the system api naming ApplicationStartInfo

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.

This telemetry is not unique to Android and its APIs, we can be a bit more precise, maybe even app_start_reason?

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 checked with @simaoseica-dd , he confirmed that this is not possible to get on IOS, so it's an Android specific field.

@ambushwork
ambushwork force-pushed the yl/profiling/update-start-reasons branch 2 times, most recently from 11a2d05 to 0df80be Compare March 11, 2026 10:53
@ambushwork
ambushwork force-pushed the yl/profiling/update-start-reasons branch from 0df80be to 77733bd Compare March 18, 2026 09:53
@ambushwork
ambushwork requested a review from 0xnm March 18, 2026 09:54
@ambushwork
ambushwork merged commit fa94b9d into develop Mar 18, 2026
26 checks passed
@ambushwork
ambushwork deleted the yl/profiling/update-start-reasons branch March 18, 2026 10:51
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