To include the Datadog integration for Coil in your project, add the
following to your application's build.gradle
file.
dependencies {
implementation "com.datadoghq:dd-sdk-android-rum:<latest-version>"
implementation "com.datadoghq:dd-sdk-android-okhttp:<latest-version>"
implementation "com.datadoghq:dd-sdk-android-coil:<latest-version>"
}
- Setup RUM monitoring, see the dedicated Datadog Android RUM Collection documentation to learn how.
- Setup OkHttp instrumentation with Datadog RUM SDK, see the dedicated documentation to learn how.
Follow Coil's API documentation to:
- Create your own
ImageLoader
by providing your ownOkHttpClient
(configured withDatadogInterceptor
).
val imageLoader = ImageLoader.Builder(context).okHttpClient(okHttpClient).build()
Coil.setImageLoader(imageLoader)
- Decorate the
ImageRequest.Builder
with theDatadogCoilRequestListener
whenever you perform an image loading request.
imageView.load(uri) {
listener(DatadogCoilRequestListener())
}
This automatically tracks Coil's network requests (creating both APM Traces and RUM Resource events), and listens for disk cache errors (creating RUM Error events).
For details on contributing, read the Contributing Guide.