Skip to content

Commit ac1bfdf

Browse files
Update Android and iOS profiling documentation to include continuous profiling for TTFD, long tasks, ANRS, and App Hangs (#37940)
* Updated Android and iOS profiling documentation to include continuous profiling for TTFD, long tasks, ANRS, and App Hangs * added screenshots for profiled iOS app hangs and Android ANRs * Updated documentation and added profiled operations * Updated reference links * Updated Android profiling operation event image * Updated iOS profiling screenshot
1 parent 0a1efc2 commit ac1bfdf

9 files changed

Lines changed: 105 additions & 44 deletions

File tree

content/en/real_user_monitoring/correlate_with_other_telemetry/profiling/_index.mdoc.md

Lines changed: 105 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,16 @@ Android Profiling is in Preview.
203203
204204
{% img src="real_user_monitoring/android/android-profiling-ttid.png" alt="Android profiling data in a time to initial display vital event." style="width:90%;" /%}
205205
206-
Android profiling captures detailed data about your application's performance during launch, helping you identify slow methods and optimize startup time. Android profiling is built on top of the [ProfilingManager Android API][4] and samples the device's CPU to collect method call stacks from the application's process.
206+
Android profiling helps you identify and optimize slow methods during important moments in user sessions. Android profiling is built on top of the [ProfilingManager Android API][4] and samples the device's CPU to collect method call stacks from the application's process.
207207
208208
{% alert level="warning" %}
209209
Only devices running Android 15 (API level 35) or higher generate profiling data.
210210
{% /alert %}
211211
212212
## Prerequisites
213213
214-
- Your Android application must use the Datadog Android SDK version 3.6.0+.
214+
- Application launch profiling requires Android SDK version 3.6.0+.
215+
- Continuous profiling requires Android SDK version 3.12.0+.
215216
- [RUM without Limits][5] must be enabled in your organization.
216217
217218
## Setup
@@ -222,59 +223,83 @@ To start collecting data, set up [Mobile RUM for Android][6].
222223
223224
### Step 2 - Configure the profiling sampling rate
224225
225-
1. Initialize the RUM SDK and configure the `applicationLaunchSampleRate`, which determines the percentage of application launches that are profiled (for example, 15% means profiling runs on 15 out of 100 launches).
226+
Initialize the RUM SDK and configure the `setApplicationLaunchSampleRate` and `setContinuousSampleRate` parameters, which are independent of each other:
226227
227-
{% alert level="danger" %}
228-
If no value is specified, the default `applicationLaunchSampleRate` is 15 percent.
229-
{% /alert %}
228+
- `setApplicationLaunchSampleRate` determines how often the time to initial display is profiled (for example, 15 means profiling runs on 15 out of 100 launches).
229+
- `setContinuousSampleRate` determines whether the time to full display, application not responding (ANR) errors, long tasks, or [RUM Operations][19] are profiled (for example, 15 means that 15 out of 100 sessions will have their time to full display, ANRs, and long tasks profiled).
230230
231-
```kotlin
232-
class SampleApplication : Application() {
233-
override fun onCreate() {
234-
super.onCreate()
235-
val configuration = Configuration.Builder(
236-
clientToken = "<CLIENT_TOKEN>",
237-
env = "<ENV_NAME>",
238-
variant = "<APP_VARIANT_NAME>"
239-
).build()
231+
Both sample rates are applied on top of the [RUM session sampling rate][17].
240232
241-
Datadog.initialize(this, configuration, trackingConsent)
233+
{% alert level="danger" %}
234+
If no value is specified, the default for both `setApplicationLaunchSampleRate` and `setContinuousSampleRate` is 15%.
235+
{% /alert %}
242236
243-
// Enable RUM (required for Profiling)
244-
val rumConfig = RumConfiguration.Builder(applicationId)
237+
```kotlin
238+
class SampleApplication : Application() {
239+
override fun onCreate() {
240+
super.onCreate()
241+
val configuration = Configuration.Builder(
242+
clientToken = "<CLIENT_TOKEN>",
243+
env = "<ENV_NAME>",
244+
variant = "<APP_VARIANT_NAME>"
245+
).build()
246+
247+
Datadog.initialize(this, configuration, trackingConsent)
248+
249+
// Enable RUM (required for Profiling)
250+
val rumConfig = RumConfiguration.Builder(applicationId)
251+
.build()
252+
Rum.enable(rumConfig)
253+
254+
// Enable Profiling
255+
Profiling.enable(
256+
ProfilingConfiguration.Builder()
257+
.setApplicationLaunchSampleRate(15f)
258+
.setContinuousSampleRate(15f)
245259
.build()
246-
Rum.enable(rumConfig)
247-
248-
// Enable Profiling
249-
val profilingConfig = ProfilingConfiguration.Builder()
250-
.setApplicationLaunchSampleRate(15) // default is 15%
251-
.build()
252-
253-
Profiling.enable(profilingConfig)
254-
}
260+
)
255261
}
256-
```
262+
}
263+
```
257264
258-
{% alert level="warning" %}
259-
The total volume of profiles may not match the percentage configured in `applicationLaunchSampleRate`. This variation results from [rate limitations](https://developer.android.com/topic/performance/tracing/profiling-manager/will-my-profile-always-be-collected#how-rate-limiting-works) within the data collector, including profiling support on older devices and the maximum profiling frequency per device.
260-
{% /alert %}
265+
{% alert level="warning" %}
266+
The total volume of profiles may not match the percentage configured in `applicationLaunchSampleRate` or `continuousSampleRate`. This variation results from [rate limitations][20] within the data collector, including profiling support on older devices and the maximum profiling frequency per device.
267+
{% /alert %}
261268
262269
The [ProfilingManager API][7] also supports disabling rate limiting during debug builds.
263270
264271
## Explore profiling data
265272
266-
Profiling data is captured on vitals and rolls up to views and sessions. Use `@profiling.has_profile` in the Sessions Explorer to filter to profiled events and investigate which code ran and how it affected the user's experience. This is available for sessions, views, and vitals.
273+
You can use the `@profiling.has_profile` attribute in the Sessions Explorer to filter to profiled events and investigate which code ran and how it affected the user's experience. This is available for sessions, views, errors, long tasks, vitals, and operations.
267274

268-
### During the time to initial display
275+
### During the time to initial display and time to full display
269276

270-
Android application launch profiling data is attached to the [time to initial display][8] vital event in a RUM session. You can access the time to initial display from the session side panel, view side panel, or directly from the time to initial display vital side panel.
277+
Android application launch profiling data is attached to the [time to initial display][8] and [time to full display][8] vital events in a RUM session. You can access profiles for the time to initial display and time to full display from the session side panel, view side panel, or directly from the vital side panels.
271278

272-
{% img src="real_user_monitoring/android/android-profiling-session.png" alt="Android profiling data in RUM session." style="width:90%;" /%}
279+
{% img src="real_user_monitoring/android/android-profiling-ttfd.png" alt="Android profiling data for a time to full display event." style="width:90%;" /%}
273280

274281
Use the **flame graph** to identify which methods consume the most CPU time during launch, the **thread timeline** to see parallel execution patterns, and the **call graph** to trace method dependencies. You can also download the profiling data for external analysis or deeper investigation.
275282

276283
{% img src="real_user_monitoring/android/android-profiling-thread-timeline.png" alt="Android profiling data for the time to initial display in a thread timeline." style="width:90%;" /%}
277284

285+
### During application not responding errors
286+
287+
Android profiling data is attached to [application not responding (ANR)][16] errors in a RUM session. You can access profiles for ANR errors from the view side panel or from the error event side panel.
288+
289+
{% img src="real_user_monitoring/android/android-profiling-anr.png" alt="Android profiling data for an application not responding error event." style="width:90%;" /%}
290+
291+
### During long tasks
292+
293+
Android profiling data is attached to long task events in a RUM session. You can access profiles for long tasks from the view side panel or from the long task event side panel.
294+
295+
{% img src="real_user_monitoring/android/android-profiling-long-task.png" alt="Android profiling data for a long task event." style="width:90%;" /%}
296+
297+
### During operations
298+
299+
Android profiling data is attached to operations events in a RUM session. You can access profiles for operations from the view side panel or from the operations event side panel.
300+
301+
{% img src="real_user_monitoring/android/android-profiling-operation.png" alt="Android profiling data for an operation." style="width:90%;" /%}
302+
278303
{% /if %}
279304
<!-- end Android -->
280305

@@ -287,11 +312,12 @@ iOS Profiling is in Preview.
287312

288313
{% img src="real_user_monitoring/ios/ios-profiling-ttid.png" alt="iOS profiling data in a time to initial display vital event." style="width:90%;" /%}
289314

290-
iOS profiling captures detailed data about your application's performance during launch, helping you identify slow functions and optimize startup time. iOS profiling is built on top of the [mach Kernel API][9] and periodically samples all application threads to collect call stacks.
315+
iOS profiling helps you identify and optimize slow methods during important moments in user sessions. iOS profiling is built on top of the [mach Kernel API][9] and periodically samples all application threads to collect call stacks.
291316

292317
## Prerequisites
293318

294-
- Your iOS application must use the Datadog iOS SDK version 3.6.0+.
319+
- Application launch profiling requires iOS SDK version 3.6.0+.
320+
- Continuous profiling requires iOS SDK version 3.14.0+.
295321
- [RUM without Limits][10] must be enabled in your organization.
296322

297323
## Setup
@@ -301,10 +327,15 @@ To start collecting data, set up [Mobile RUM for iOS][11].
301327

302328
### Step 2 - Configure the profiling sampling rate
303329

304-
Initialize the RUM SDK and configure the `applicationLaunchSampleRate`, which determines the percentage of application launches that are profiled (for example, 5% means profiling runs on 5 out of 100 launches).
330+
Initialize the RUM SDK and configure the `applicationLaunchSampleRate` and `continuousSampleRate` parameters, which are independent of each other:
331+
332+
- `applicationLaunchSampleRate` determines how often the time to initial display is profiled (for example, 5 means profiling runs on 5 out of 100 launches).
333+
- `continuousSampleRate` determines whether the time to full display, application hangs, long tasks, or [RUM Operations] [21] are profiled (for example, 5 means that 5 out of 100 sessions will have their time to full display, application hangs, and long tasks profiled).
334+
335+
Both sample rates are applied on top of the [RUM session sampling rate][21].
305336

306337
{% alert level="danger" %}
307-
If no value is specified, the default `applicationLaunchSampleRate` is 5 percent.
338+
If no value is specified, the default for both `applicationLaunchSampleRate` and `continuousSampleRate` is 5%.
308339
{% /alert %}
309340

310341
```swift
@@ -330,23 +361,47 @@ If no value is specified, the default `applicationLaunchSampleRate` is 5 percent
330361
)
331362
332363
// Enable Profiling feature
333-
Profiling.enable() // default is 5%
364+
Profiling.enable(with:
365+
Profiling.Configuration(
366+
applicationLaunchSampleRate: 5.0,
367+
continuousSampleRate: 5.0
368+
)
369+
)
334370
```
335371

336372
## Explore profiling data
337373

338-
Profiling data is captured on vitals and rolls up to views and sessions. Use `@profiling.has_profile` in the Sessions Explorer to filter to profiled events and investigate which code ran and how it affected the user's experience. This is available for sessions, views, and vitals.
374+
You can use the `@profiling.has_profile`attribute in the Sessions Explorer to filter to profiled events and investigate which code ran and how it affected the user's experience. This is available for sessions, views, errors, long tasks, vitals, and operations.
339375
340-
### During the time to initial display
376+
### During the time to initial display and time to full display
341377
342-
iOS application launch profiling data is attached to the [time to initial display][12] vital event in a RUM session. You can access the time to initial display from the session side panel, view side panel, or directly from the time to initial display vital side panel.
378+
iOS application launch profiling data is attached to the [time to initial display][12] and [time to full display][12] vital events in a RUM session. You can access profiles for the time to initial display and time to full display from the session side panel, view side panel, or directly from the vital side panels.
343379
344-
{% img src="real_user_monitoring/ios/ios-profiling-session.png" alt="iOS profiling data in a view event to initial display vital event." style="width:90%;" /%}
380+
{% img src="real_user_monitoring/ios/ios-profiling-ttfd.png" alt="iOS profiling data in a time to full display vital event." style="width:90%;" /%}
345381
346382
Use the **flame graph** to identify which functions consume the most Wall time during launch, the **thread timeline** to see parallel execution patterns, and the **call graph** to trace function dependencies. You can also download the profiling data for external analysis or deeper investigation.
347383
348384
{% img src="real_user_monitoring/ios/ios-profiling-thread-timeline.png" alt="iOS profiling data for the time to initial display in a thread timeline." style="width:90%;" /%}
349385
386+
### During application hangs
387+
388+
iOS profiling data is attached to [application hangs][18] in a RUM session. You can access profiles for application hangs from the view side panel or from the error event side panel.
389+
390+
{% img src="real_user_monitoring/ios/ios-profiling-app-hang.png" alt="iOS profiling data in an application hang event." style="width:90%;" /%}
391+
392+
### During long tasks
393+
394+
iOS profiling data is attached to long task events in a RUM session. You can access profiles for long tasks from the view side panel or from the long task event side panel.
395+
396+
{% img src="real_user_monitoring/ios/ios-profiling-long-task.png" alt="iOS profiling data in a long task event." style="width:90%;" /%}
397+
398+
### During operations
399+
400+
iOS profiling data is attached to operations events in a RUM session. You can access profiles for operations from the view side panel or from the operations event side panel.
401+
402+
{% img src="real_user_monitoring/ios/ios-profiling-operation.png" alt="iOS profiling data in an operation event." style="width:90%;" /%}
403+
404+
350405
{% /if %}
351406
<!-- end iOS -->
352407
@@ -365,3 +420,9 @@ Use the **flame graph** to identify which functions consume the most Wall time d
365420
[13]: /real_user_monitoring/guide/proxy-rum-data
366421
[14]: /integrations/content_security_policy_logs
367422
[15]: /real_user_monitoring/#supported-endpoints-for-sdk-domains
423+
[16]: /real_user_monitoring/application_monitoring/android/data_collected#error-attributes
424+
[17]: /real_user_monitoring/application_monitoring/android/setup?tab=kotlin#sample-session-rates-2
425+
[18]: /real_user_monitoring/application_monitoring/ios/data_collected#error-attributes
426+
[19]: /real_user_monitoring/operations_monitoring/?tab=browser
427+
[20]: https://developer.android.com/topic/performance/tracing/profiling-manager/will-my-profile-always-be-collected#how-rate-limiting-works
428+
[21]: /real_user_monitoring/application_monitoring/ios/setup?tab=swift-package-manager--spm
310 KB
Loading
327 KB
Loading
384 KB
Loading
414 KB
Loading
382 KB
Loading
357 KB
Loading
378 KB
Loading
435 KB
Loading

0 commit comments

Comments
 (0)