Overview
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 and samples the device’s CPU to collect method call stacks from the application’s process.
Only devices running Android 15 (API level 35) or higher generate profiling data.
Prerequisites
- Your Android application must use the Datadog Android SDK version 3.6.0+.
- RUM without Limits must be enabled in your organization.
Setup
- Set up Mobile RUM for Android.
- 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).
If no value is specified, the default applicationLaunchSampleRate is 15 percent.
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)
// Enable RUM (required for Profiling)
val rumConfig = RumConfiguration.Builder(applicationId)
.build()
Rum.enable(rumConfig)
// Enable Profiling
val profilingConfig = ProfilingConfiguration.Builder()
.setApplicationLaunchSampleRate(15) // default is 15%
.build()
Profiling.enable(profilingConfig)
}
}
The total volume of profiles may not match the percentage configured in
applicationLaunchSampleRate. This variation results from
rate limitations within the data collector, including profiling support on older devices and the maximum profiling frequency per device.
The ProfilingManager API also supports disabling rate limiting during debug builds.
Explore profiling data
During the time to initial display
Android application launch profiling data is attached to the time to initial display 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.
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.
Further Reading
Additional helpful documentation, links, and articles: