- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
",t};e.buildCustomizationMenuUi=t;function n(e){let t='
",t}function s(e){let n=e.filter.currentValue||e.filter.defaultValue,t='${e.filter.label}
`,e.filter.options.forEach(s=>{let o=s.id===n;t+=``}),t+="${e.filter.label}
`,t+=`— title: Jetpack Compose Instrumentation description: Instrument Jetpack Compose manually or automatically using the Datadog Gradle Plugin. aliases:
Jetpack Compose is a toolkit for building native UI in Android. If your application uses Jetpack Compose, you can instrument it manually or automatically with the Datadog Gradle Plugin. This enables Real User Monitoring (RUM) similar to what is available for Android classic Views.
The minimum supported Kotlin version is 1.9.23.
After initial setup, you can choose between automatic and manual instrumentation.
Add dd-sdk-android-compose
as a dependency to each module you want to instrument. This includes the application module, any Jetpack Compose UI modules, or feature modules using Jetpack Compose.
The minimum version of dd-sdk-android-compose
for Jetpack Compose instrumentation is 2.21.0.
dependencies {
implementation "com.datadoghq:dd-sdk-android-compose:x.x.x"
//(...)
}
dependencies {
implementation("com.datadoghq:dd-sdk-android-compose:x.x.x")
//(...)
}
RumConfiguration
After adding the dependency, enable Compose action tracking in your RumConfiguration
. This step is required regardless of the instrumentation mode.
val rumConfig = RumConfiguration.Builder(applicationId)
//other configurations that you have already set
.enableComposeActionTracking()
.build()
Rum.enable(rumConfig)
RumConfiguration rumConfig = new RumConfiguration.Builder(applicationId)
//other configurations that you have already set
.enableComposeActionTracking()
.build();
Rum.enable(rumConfig);
For full RUM coverage with minimal setup, you can automatically instrument your Jetpack Compose application.
As described in Step 1 of the Android setup section, declare the Datadog Gradle Plugin in your build script and apply it to each module you want to instrument.
The Datadog Gradle Plugin scans @Composable
functions and adds Semantics tags to their modifiers. These tags allow Datadog RUM to track user interactions on Compose components with the correct target information. The plugin also detects NavHost
usage and listens to Jetpack Compose navigation events.
The minimum version of Datadog Gradle Plugin for Jetpack Compose instrumentation is 1.17.0.
buildscript {
dependencies {
classpath "com.datadoghq:dd-sdk-android-gradle-plugin:x.x.x"
}
}
plugins {
id 'com.datadoghq.dd-sdk-android-gradle-plugin'
//(...)
}
buildscript {
dependencies {
classpath("com.datadoghq:dd-sdk-android-gradle-plugin:x.x.x")
}
}
plugins {
id("com.datadoghq.dd-sdk-android-gradle-plugin")
//(...)
}
In your module’s Gradle configuration, define the desired Compose instrumentation mode:
datadog {
// Other configurations that you may set before.
//(...)
// Jetpack Compose instrumentation mode option.
composeInstrumentation = InstrumentationMode.AUTO
}
datadog {
// Other configurations that you may set before.
//(...)
// Jetpack Compose instrumentation mode option.
composeInstrumentation = InstrumentationMode.AUTO
}
Available instrumentation modes:
InstrumentationMode.AUTO
: Instruments all @Composable
functions.InstrumentationMode.ANNOTATION
: Only instruments @Composable
functions annotated with @ComposeInstrumentation
. You can define the scope of auto-instrumentation by using this annotation.InstrumentationMode.DISABLE
: Disables instrumentation completely.Note: if you don’t declare composeInstrumentation
in datadog
block, the auto-instrumentation is disabled by default.
When auto-instrumentation is enabled:
@Composable
fun AppScaffold(){
NavHost(navController = rememberNavController(), startDestination = "Home Screen"){
composable("Home Screen"){
HomeScreen()
}
}
}
@Composable
fun CustomButton(onClick: () -> Unit) {
Button(onClick = onClick){
Text("Welcome Button")
}
}
In the example above:
HomeScreen()
is loaded.If you need more customization or control over actions and views tracking, you can manually instrument your application(s).
To track user interactions with specific Jetpack Compose components, apply the datadog
modifier. The name
argument defines the view name displayed in the RUM event list.
@Composable
fun HomeScreen(){
Column{
Image(modifier = Modifier.datadog(name = "Welcome Image").clickable{
// Action can be tracked if this image is clickable
},
// Other arguments
)
Text(modifier = Modifier.datadog(name = "Welcome Text").clickable{
// Action can be tracked if this text is clickable
},
// Other arguments
)
}
}
In the example above, the custom names are used for the interactive elements in Rum actions tracking.
To enable RUM view tracking based on Jetpack Compose navigation, call the NavigationViewTrackingEffect
API and pass your app’s NavHostController
.
@Composable
fun AppScaffold(){
val navController = rememberNavController()
NavigationViewTrackingEffect(
navController = navController,
trackArguments = true,
destinationPredicate = AcceptAllNavDestinations()
)
NavHost(navController = navController,
// other arguments
) {
// (...)
}
}
추가 유용한 문서, 링크 및 기사: