-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Monitor app launch performance for iOS and Android in RUM #33710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
arti-arutiunov
wants to merge
7
commits into
master
Choose a base branch
from
Arti-Arutiunov/rum-mobile-app-launch
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1cec0f8
New iOS and Android pages to monitor application performance in RUM
arti-arutiunov 03b34cf
Merge branch 'master' into Arti-Arutiunov/rum-mobile-app-launch
arti-arutiunov 73c489c
Cleaned up documentation in accordance with our style guidelines
arti-arutiunov e218d7e
Rearranged warning banner for legacy SDK versions
arti-arutiunov 2c1a1bd
Update app launch summary screenshots
arti-arutiunov 5471e8d
Cleaning up documentation
arti-arutiunov 9f5c711
Updated links for Android TTFD API
arti-arutiunov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
...user_monitoring/application_monitoring/android/application_launch_monitoring.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| --- | ||
| title: Android Mobile App Launch Monitoring | ||
| description: "Measure Android mobile application launch performance, including the time to initial display and time to full display." | ||
| aliases: | ||
| - /real_user_monitoring/android/application_launch_monitoring/ | ||
| - /real_user_monitoring/mobile_and_tv_monitoring/application_launch_monitoring/android | ||
| - /real_user_monitoring/mobile_and_tv_monitoring/android/application_launch_monitoring | ||
| further_reading: | ||
| - link: https://github.com/DataDog/dd-sdk-android | ||
| tag: "Source Code" | ||
| text: Source code for dd-sdk-android | ||
| - link: /real_user_monitoring | ||
| tag: Documentation | ||
| text: Explore Datadog RUM | ||
| --- | ||
|
|
||
| ## Overview | ||
|
|
||
| Application launch monitoring helps you understand how fast your Android app becomes usable after a user taps the app icon. Use it to identify slow startup times, track performance regressions, and optimize the user’s first impression of your app. | ||
|
|
||
| With this feature, you can: | ||
| - Measure time to initial display (TTID) and time to full display (TTFD) for cold and warm starts | ||
| - View launch performance trends in the RUM Summary and Mobile Performance Dashboard | ||
| - Drill into individual launch events to diagnose bottlenecks | ||
|
|
||
| ## How it works | ||
|
|
||
| During initialization, the RUM Android SDK creates a view called `ApplicationLaunch`. This view’s start time matches the start of the Android process. The `ApplicationLaunch` view includes any logs, actions, and resources created before your first call to `startView`. | ||
|
|
||
| <div class="alert alert-danger"> | ||
| The <code>application_start</code> action is not collected in Android SDK versions 3.5.0+. The <code>rum.measure.app.startup_time metric</code> is marked as deprecated but continues to report data from devices running app versions that use older SDK versions. | ||
| </div> | ||
|
|
||
| ### Time to initial display and time to full display | ||
|
|
||
| In Android SDK versions 3.5.0+, the time to initial display (TTID) and time to full display (TTFD) are collected during the application launch period. | ||
|
|
||
| | Measurement | Summary | Details | | ||
| |----------------|----------|----------------------------------------------------------------------------------------------------------------------------------| | ||
| | [Time to initial display][1] | The time it takes to display the first frame of the app's UI. | The time taken for an app to produce its first frame, including process initialization during a cold start, activity creation during a cold or warm start, and displaying the first frame. | | ||
| | [Time to full display][2] | The time it takes for an app to become interactive for the user. | The time taken to display the first frame of the app's UI, as well as the content that loads asynchronously after the initial frame is displayed. | | ||
|
|
||
| Each time to initial display and time to full display is categorized by launch type: | ||
| - [Cold start][3]: The application is launched from scratch. Cold starts happen when the application is launched for the first time since device boot or since the system terminated the process of the application. | ||
| - [Warm start][4]: The application is launched using a subset of the operations that take place during a cold start. Warm starts result from situations such as a user backing out of the application or re-launching the application. Warm starts can also result from the user launching the `Activity` when the OS-process already exists, such as the arrival of a silent push or `WorkManager` job execution. | ||
|
|
||
| ### Measuring the time to initial display | ||
| The Android SDK automatically measures the TTID. The TTID can be optionally profiled using the Android Mobile Profiler. | ||
|
|
||
| ### Measuring the time to full display | ||
| The time to full display is manually defined using the `GlobalRumMonitor.get().reportAppFullyDisplayed()` API in the Android SDK based on the application’s specific definition of “fully drawn.” | ||
|
|
||
| Below is an example where time to full display is determined when home activity is fully loaded. | ||
|
|
||
| {{< tabs >}} | ||
| {{% tab "Kotlin" %}} | ||
|
|
||
| ```kotlin | ||
| class SampleApplication : Application() { | ||
| override fun onCreate() { | ||
| super.onCreate() | ||
| val configuration = Configuration.Builder( | ||
| clientToken = "<CLIENT_TOKEN>", | ||
| env = "<ENV_NAME>", | ||
| variant = "<APP_VARIANT_NAME>" | ||
| ).build() | ||
|
|
||
| Datadog.initialize(this, configuration, trackingConsent) | ||
| } | ||
| } | ||
| ``` | ||
| {{% /tab %}} | ||
| {{< /tabs >}} | ||
|
|
||
| If you use `reportFullyDrawn` to identify the moment of full display, you can use [getFullyDrawnReporter][7] to subscribe to `reportFullyDrawn` and call `GlobalRumMonitor.get().reportAppFullyDisplayed()`. | ||
|
|
||
| <div class="alert alert-danger"> | ||
| If the time to full display is not defined, the Android SDK only collects the TTID. | ||
| </div> | ||
|
|
||
| ### RUM summary | ||
|
|
||
| The TTID and TTFD are presented in the RUM Summary under Mobile Performance. The standalone Mobile Performance Dashboard also contains distribution visuals for TTID and TTFD. | ||
|
|
||
| {{< img src="real_user_monitoring/android/android-rum-summary-app-launch.png" alt="Android RUM Summary" style="width:90%;">}} | ||
|
|
||
| ### Vital events | ||
|
|
||
| The time to initial display and time to full display are presented as vital events in the RUM session. They are also found under the first view after the `ApplicationLaunch` view. TTID and TTFD are captured if the user launches the application in the session. Neither the TTID nor the TTFD appear if the user does not launch the application during the session. | ||
|
|
||
| {{< img src="real_user_monitoring/android/android-app-launch-session.png" alt="Android session side panel" style="width:90%;">}} | ||
|
|
||
|
|
||
| The TTID and TTFD can be queried in the RUM Sessions Explorer using the following attributes on the vital event type: | ||
| - `@vital.type:app_launch` | ||
| - `@vital.name:time_to_initial_display` or `@vital.name:time_to_full_display` | ||
|
|
||
| Each TTID and TTFD side panel contains a distribution visualization, an indication of whether the launch was cold or warm, and an event waterfall. | ||
|
|
||
| {{< img src="real_user_monitoring/android/android-ttid-vital.png" alt="Time to initial display vital event" style="width:90%;">}} | ||
|
|
||
| If Android profiling is enabled and the session is sampled, the time to initial display may include profiling data. | ||
|
|
||
| ### Metrics | ||
| The time to initial display and time to full display are calculated as metrics: | ||
| - `rum.measure.app.startup_to_initial_display`, which represents the time to initial display | ||
| - `rum.measure.app.startup_to_full_display`, which represents the time to full display | ||
|
|
||
| These metrics contain the `@vital.startup_type` attribute to specify the launch type for accurate monitoring. | ||
|
|
||
| <div class="alert alert-danger"> | ||
| The <code>rum.measure.app.startup_to_full_display</code> metric is not calculated if the time to full display is undefined. | ||
| </div> | ||
|
|
||
| ## Further reading | ||
|
|
||
| {{< partial name="whats-next/whats-next.html" >}} | ||
|
|
||
| [1]: https://developer.android.com/topic/performance/vitals/launch-time#time-initial | ||
| [2]: https://developer.android.com/topic/performance/vitals/launch-time#time-full | ||
| [3]: https://developer.android.com/topic/performance/vitals/launch-time#cold | ||
| [4]: https://developer.android.com/topic/performance/vitals/launch-time#warm | ||
| [5]: https://developer.android.com/reference/android/app/Activity#reportFullyDrawn() | ||
| [6]: https://developer.android.com/reference/androidx/activity/ComponentActivity#getFullyDrawnReporter%28%29 | ||
| [7]: https://developer.android.com/reference/androidx/activity/ComponentActivity#getFullyDrawnReporter() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code snippet shows only core SDK setup, should it include example of
reportAppFullyDisplayedcall?upd: like for iOS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@0xnm Yes, it should. I generated this with AI, so please let me know if it an incorrect equivalent:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good! sorry for missing this comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code snippet above can work, but there are two issues as a demo in the documentation from what I see:
So I suggest to change to following code snippet,
HomeViewModelis responsible for preparing theuiStateand theHomeActivityjust observes the state without exposing the data loading detail, and when the state is ready,reportAppFullyDisplayedshould be called.