With the extraction of different products into independent modules, the SDK configuration is organized by module.
com.datadog.android.core.configuration.Configuration.Builder
class has the following changes:
- Client token, env name, variant name (default value is empty string), and service name (default value is application ID taken from the manifest) should be provided in the constructor.
- The
com.datadog.android.core.configuration.Credentials
class is removed. logsEnabled
, tracesEnabled
, and rumEnabled
are removed from the constructor in favour of individual product configuration (see below).crashReportsEnabled
constructor argument is removed. You can enable or disable JVM crash reporting with the Configuration.Builder.setCrashReportsEnabled
method. By default, JVM crash reporting is enabled.- RUM, Logs, and Trace product configuration methods are removed from
Configuration.Builder
in favor of the individual product configuration (see below).
The Datadog.initialize
method has the Credentials
class removed from the list of the arguments.
The com.datadog.android.plugin
package and all related classes/methods are removed.
Logs
All the classes related to the Logs product are strictly contained in the com.datadog.android.log
package.
To use Logs product, import the following artifact:
implementation("com.datadoghq:dd-sdk-android-logs:x.x.x")
You can enable the Logs product with the following snippet:
val logsConfig = LogsConfiguration.Builder()
...
.build()
Logs.enable(logsConfig)
val logger = Logger.Builder()
...
.build()
API changes:
1.x | 2.0 |
---|
com.datadog.android.core.configuration.Configuration.Builder.setLogEventMapper | com.datadog.android.log.LogsConfiguration.Builder.setEventMapper |
com.datadog.android.core.configuration.Configuration.Builder.useCustomLogsEndpoint | com.datadog.android.log.LogsConfiguration.Builder.useCustomEndpoint |
com.datadog.android.log.Logger.Builder.setLoggerName | com.datadog.android.log.Logger.Builder.setName |
com.datadog.android.log.Logger.Builder.setSampleRate | com.datadog.android.log.Logger.Builder.setRemoteSampleRate |
com.datadog.android.log.Logger.Builder.setDatadogLogsEnabled | This method has been removed. Use com.datadog.android.log.Logger.Builder.setRemoteSampleRate(0f) instead to disable sending logs to Datadog. |
com.datadog.android.log.Logger.Builder.setServiceName | com.datadog.android.log.Logger.Builder.setService |
com.datadog.android.log.Logger.Builder.setDatadogLogsMinPriority | com.datadog.android.log.Logger.Builder.setRemoteLogThreshold |
Trace
All the classes related to the Trace product are strictly contained in the com.datadog.android.trace
package (this means that all classes residing in com.datadog.android.tracing
before have moved).
To use the Trace product, import the following artifact:
implementation("com.datadoghq:dd-sdk-android-trace:x.x.x")
You can enable the Trace product with the following snippet:
val traceConfig = TraceConfiguration.Builder()
...
.build()
Trace.enable(traceConfig)
val tracer = AndroidTracer.Builder()
...
.build()
GlobalTracer.registerIfAbsent(tracer)
API changes:
1.x | 2.0 |
---|
com.datadog.android.core.configuration.Configuration.Builder.setSpanEventMapper | com.datadog.android.trace.TraceConfiguration.Builder.setEventMapper |
com.datadog.android.core.configuration.Configuration.Builder.useCustomTracesEndpoint | com.datadog.android.trace.TraceConfiguration.Builder.useCustomEndpoint |
com.datadog.android.tracing.AndroidTracer.Builder.setSamplingRate | com.datadog.android.trace.AndroidTracer.Builder.setSampleRate |
com.datadog.android.tracing.AndroidTracer.Builder.setServiceName | com.datadog.android.trace.AndroidTracer.Builder.setService |
RUM
All classes related to the RUM product are strictly contained in the com.datadog.android.rum
package.
To use the RUM product, import the following artifact:
implementation("com.datadoghq:dd-sdk-android-rum:x.x.x")
You can enable the RUM product with the following snippet:
val rumConfig = RumConfiguration.Builder(rumApplicationId)
...
.build()
Rum.enable(rumConfig)
API changes:
1.x | 2.0 |
---|
com.datadog.android.core.configuration.Configuration.Builder.setRumViewEventMapper | com.datadog.android.rum.RumConfiguration.Builder.setViewEventMapper |
com.datadog.android.core.configuration.Configuration.Builder.setRumResourceEventMapper | com.datadog.android.rum.RumConfiguration.Builder.setResourceEventMapper |
com.datadog.android.core.configuration.Configuration.Builder.setRumActionEventMapper | com.datadog.android.rum.RumConfiguration.Builder.setActionEventMapper |
com.datadog.android.core.configuration.Configuration.Builder.setRumErrorEventMapper | com.datadog.android.rum.RumConfiguration.Builder.setErrorEventMapper |
com.datadog.android.core.configuration.Configuration.Builder.setRumLongTaskEventMapper | com.datadog.android.rum.RumConfiguration.Builder.setLongTaskEventMapper |
com.datadog.android.core.configuration.Configuration.Builder.useCustomRumEndpoint | com.datadog.android.rum.RumConfiguration.Builder.useCustomEndpoint |
com.datadog.android.event.ViewEventMapper | com.datadog.android.rum.event.ViewEventMapper |
com.datadog.android.core.configuration.VitalsUpdateFrequency | com.datadog.android.rum.configuration.VitalsUpdateFrequency |
com.datadog.android.core.configuration.Configuration.Builder.trackInteractions | com.datadog.android.rum.RumConfiguration.Builder.trackUserInteractions |
com.datadog.android.core.configuration.Configuration.Builder.disableInteractionTracking | com.datadog.android.rum.RumConfiguration.Builder.disableUserInteractionTracking |
com.datadog.android.core.configuration.Configuration.Builder.sampleRumSessions | com.datadog.android.rum.RumConfiguration.Builder.setSessionSampleRate |
com.datadog.android.core.configuration.Configuration.Builder.sampleTelemetry | com.datadog.android.rum.RumConfiguration.Builder.setTelemetrySampleRate |
com.datadog.android.rum.RumMonitor.Builder | This class has been removed. The RUM monitor is created and registered during the Rum.enable call. |
com.datadog.android.rum.RumMonitor.Builder.sampleRumSessions | com.datadog.android.rum.RumConfiguration.Builder.setSessionSampleRate |
com.datadog.android.rum.RumMonitor.Builder.setSessionListener | com.datadog.android.rum.RumConfiguration.Builder.setSessionListener |
com.datadog.android.rum.RumMonitor.addUserAction | com.datadog.android.rum.RumMonitor.addAction |
com.datadog.android.rum.RumMonitor.startUserAction | com.datadog.android.rum.RumMonitor.startAction |
com.datadog.android.rum.RumMonitor.stopUserAction | com.datadog.android.rum.RumMonitor.stopAction |
com.datadog.android.rum.GlobalRum.registerIfAbsent | This method has been removed. The RUM monitor is created and registered during the Rum.enable call. |
com.datadog.android.rum.GlobalRum | com.datadog.android.rum.GlobalRumMonitor |
com.datadog.android.rum.GlobalRum.addAttribute | com.datadog.android.rum.RumMonitor.addAttribute |
com.datadog.android.rum.GlobalRum.removeAttribute | com.datadog.android.rum.RumMonitor.removeAttribute |
NDK Crash Reporting
The artifact name stays the same as before: com.datadoghq:dd-sdk-android-ndk:x.x.x
.
You can enable NDK Crash Reporting with the following snippet:
This configuration replaces the com.datadog.android.core.configuration.Configuration.Builder.addPlugin
call.
Note: You should have RUM and Logs products enabled to receive NDK crash reports in RUM and Logs respectively.
WebView Tracking
The artifact name stays the same as before: com.datadoghq:dd-sdk-android-webview:x.x.x
You can enable WebView Tracking with the following snippet:
WebViewTracking.enable(webView, allowedHosts)
Note: You should have RUM and Logs products enabled to receive events coming from WebView in RUM and Logs respectively.
API changes:
1.x | 2.0 |
---|
com.datadog.android.webview.DatadogEventBridge | This method became an internal class. Use WebViewTracking instead. |
com.datadog.android.rum.webview.RumWebChromeClient | This class was removed. Use WebViewTracking instead. |
com.datadog.android.rum.webview.RumWebViewClient | This class was removed. Use WebViewTracking instead. |
OkHttp Tracking
To use OkHttp Tracking, import the following artifact:
implementation("com.datadoghq:dd-sdk-android-okhttp:x.x.x")
OkHttp instrumentation supports the initialization of the Datadog SDK after the OkHttp client, allowing you to create com.datadog.android.okhttp.DatadogEventListener
, com.datadog.android.okhttp.DatadogInterceptor
, and com.datadog.android.okhttp.trace.TracingInterceptor
before the Datadog SDK. OkHttp instrumentation starts reporting events to Datadog once the Datadog SDK is initialized.
Both com.datadog.android.okhttp.DatadogInterceptor
and com.datadog.android.okhttp.trace.TracingInterceptor
allow you to control sampling dynamically through integration with a remote configuration system.
To dynamically adjust sampling, provide your own implementation of the com.datadog.android.core.sampling.Sampler
interface in the com.datadog.android.okhttp.DatadogInterceptor
/com.datadog.android.okhttp.trace.TracingInterceptor
constructor. It is queried for each request to make the sampling decision.
dd-sdk-android-ktx
module removal
To improve granularity for the Datadog SDK libraries used, the dd-sdk-android-ktx
module is removed. The code is distributed between the other modules to provide extension methods for both RUM and Trace features.
1.x | ‘2.0’ | Module name |
---|
com.datadog.android.ktx.coroutine#kotlinx.coroutines.CoroutineScope.launchTraced | com.datadog.android.trace.coroutines#kotlinx.coroutines.CoroutineScope.launchTraced | dd-sdk-android-trace-coroutines |
com.datadog.android.ktx.coroutine#runBlockingTraced | com.datadog.android.trace.coroutines#runBlockingTraced | dd-sdk-android-trace-coroutines |
com.datadog.android.ktx.coroutine#kotlinx.coroutines.CoroutineScope.asyncTraced | com.datadog.android.trace.coroutines#kotlinx.coroutines.CoroutineScope.asyncTraced | dd-sdk-android-trace-coroutines |
com.datadog.android.ktx.coroutine#kotlinx.coroutines.Deferred<T>.awaitTraced | com.datadog.android.trace.coroutines#kotlinx.coroutines.Deferred<T>.awaitTraced | dd-sdk-android-trace-coroutines |
com.datadog.android.ktx.coroutine#withContextTraced | com.datadog.android.trace.coroutines#withContextTraced | dd-sdk-android-trace-coroutines |
com.datadog.android.ktx.coroutine.CoroutineScopeSpan | com.datadog.android.trace.coroutines.CoroutineScopeSpan | dd-sdk-android-trace-coroutines |
com.datadog.android.ktx.sqlite#android.database.sqlite.SQLiteDatabase.transactionTraced | com.datadog.android.trace.sqlite#android.database.sqlite.SQLiteDatabase.transactionTraced | dd-sdk-android-trace |
com.datadog.android.ktx.tracing#io.opentracing.Span.setError | com.datadog.android.trace#io.opentracing.Span.setError | dd-sdk-android-trace |
com.datadog.android.ktx.tracing#withinSpan | com.datadog.android.trace#withinSpan | dd-sdk-android-trace |
com.datadog.android.ktx.coroutine#sendErrorToDatadog | com.datadog.android.rum.coroutines#sendErrorToDatadog | dd-sdk-android-rum-coroutines |
com.datadog.android.ktx.rum#java.io.Closeable.useMonitored | com.datadog.android.rum#java.io.Closeable.useMonitored | dd-sdk-android-rum |
com.datadog.android.ktx.rum#android.content.Context.getAssetAsRumResource | com.datadog.android.rum.resource#android.content.Context.getAssetAsRumResource | dd-sdk-android-rum |
com.datadog.android.ktx.rum#android.content.Context.getRawResAsRumResource | com.datadog.android.rum.resource#android.content.Context.getRawResAsRumResource | dd-sdk-android-rum |
com.datadog.android.ktx.rum#java.io.InputStream.asRumResource | com.datadog.android.rum.resource#java.io.InputStream.asRumResource | dd-sdk-android-rum |
com.datadog.android.ktx.tracing#okhttp3.Request.Builder.parentSpan | com.datadog.android.okhttp.trace#okhttp3.Request.Builder.parentSpan | dd-sdk-android-okhttp |
セッション リプレイ
For instructions on setting up Mobile Session Replay, see Mobile Session Replay Setup and Configuration.
With the extraction of different products into independent modules, the SDK configuration is organized by module.
The SDK must be initialized before enabling any product.
The Builder pattern of the SDK initialization has been removed in favor of structure definitions. The following example shows how a 1.x
initialization would translate in 2.0
.
V1 Initialization
import Datadog
Datadog.initialize(
appContext: .init(),
trackingConsent: .granted,
configuration: Datadog.Configuration
.builderUsing(
clientToken: "<client token>",
environment: "<environment>"
)
.set(serviceName: "<service name>")
.build()
V2 Initialization
import DatadogCore
Datadog.initialize(
with: Datadog.Configuration(
clientToken: "<client token>",
env: "<environment>",
service: "<service name>"
),
trackingConsent: .granted
)
API changes:
1.x | 2.0 |
---|
Datadog.Configuration.Builder.set(serviceName:) | Datadog.Configuration.service |
Datadog.Configuration.Builder.set(batchSize:) | Datadog.Configuration.batchSize |
Datadog.Configuration.Builder.set(uploadFrequency:) | Datadog.Configuration.uploadFrequency |
Datadog.Configuration.Builder.set(proxyConfiguration:) | Datadog.Configuration.proxyConfiguration |
Datadog.Configuration.Builder.set(encryption:) | Datadog.Configuration.encryption |
Datadog.Configuration.Builder.set(serverDateProvider:) | Datadog.Configuration.serverDateProvider |
Datadog.AppContext(mainBundle:) | Datadog.Configuration.bundle |
Logs
All the classes related to Logs are strictly in the DatadogLogs
module. You first need to enable the product:
import DatadogLogs
Logs.enable(with: Logs.Configuration(...))
Then, you can create a logger instance:
import DatadogLogs
let logger = Logger.create(
with: Logger.Configuration(name: "<logger name>")
)
API changes:
1.x | 2.0 |
---|
Datadog.Configuration.Builder.setLogEventMapper(_:) | Logs.Configuration.eventMapper |
Datadog.Configuration.Builder.set(loggingSamplingRate:) | Logs.Configuration.eventMapper |
Logger.Builder.set(serviceName:) | Logger.Configuration.service |
Logger.Builder.set(loggerName:) | Logger.Configuration.name |
Logger.Builder.sendNetworkInfo(_:) | Logger.Configuration.networkInfoEnabled |
Logger.Builder.bundleWithRUM(_:) | Logger.Configuration.bundleWithRumEnabled |
Logger.Builder.bundleWithTrace(_:) | Logger.Configuration.bundleWithTraceEnabled |
Logger.Builder.sendLogsToDatadog(false) | Logger.Configuration.remoteSampleRate = 0 |
Logger.Builder.set(datadogReportingThreshold:) | Logger.Configuration.remoteLogThreshold |
Logger.Builder.printLogsToConsole(_:, usingFormat) | Logger.Configuration.consoleLogFormat |
Trace
All the classes related to Trace are strictly in the DatadogTrace
module. You first need to enable the product:
import DatadogTrace
Trace.enable(
with: Trace.Configuration(...)
)
Then, you can access the shared Tracer instance:
import DatadogTrace
let tracer = Tracer.shared()
API changes:
1.x | 2.0 |
---|
Datadog.Configuration.Builder.trackURLSession(_:) | Trace.Configuration.urlSessionTracking |
Datadog.Configuration.Builder.setSpanEventMapper(_:) | Trace.Configuration.eventMapper |
Datadog.Configuration.Builder.set(tracingSamplingRate:) | Trace.Configuration.sampleRate |
Tracer.Configuration.serviceName | Trace.Configuration.service |
Tracer.Configuration.sendNetworkInfo | Trace.Configuration.networkInfoEnabled |
Tracer.Configuration.globalTags | Trace.Configuration.tags |
Tracer.Configuration.bundleWithRUM | Trace.Configuration.bundleWithRumEnabled |
Tracer.Configuration.samplingRate | Trace.Configuration.sampleRate |
RUM
All the classes related to RUM are strictly in the DatadogRUM
module. You first need to enable the product:
import DatadogRUM
RUM.enable(
with: RUM.Configuration(applicationID: "<RUM Application ID>")
)
Then, you can access the shared RUM monitor instance:
import DatadogRUM
let monitor = RUMMonitor.shared()
API changes:
1.x | 2.0 |
---|
Datadog.Configuration.Builder.trackURLSession(_:) | RUM.Configuration.urlSessionTracking |
Datadog.Configuration.Builder.set(rumSessionsSamplingRate:) | RUM.Configuration.sessionSampleRate |
Datadog.Configuration.Builder.onRUMSessionStart | RUM.Configuration.onSessionStart |
Datadog.Configuration.Builder.trackUIKitRUMViews(using:) | RUM.Configuration.uiKitViewsPredicate |
Datadog.Configuration.Builder.trackUIKitRUMActions(using:) | RUM.Configuration.uiKitActionsPredicate |
Datadog.Configuration.Builder.trackRUMLongTasks(threshold:) | RUM.Configuration.longTaskThreshold |
Datadog.Configuration.Builder.setRUMViewEventMapper(_:) | RUM.Configuration.viewEventMapper |
Datadog.Configuration.Builder.setRUMResourceEventMapper(_:) | RUM.Configuration.resourceEventMapper |
Datadog.Configuration.Builder.setRUMActionEventMapper(_:) | RUM.Configuration.actionEventMapper |
Datadog.Configuration.Builder.setRUMErrorEventMapper(_:) | RUM.Configuration.errorEventMapper |
Datadog.Configuration.Builder.setRUMLongTaskEventMapper(_:) | RUM.Configuration.longTaskEventMapper |
Datadog.Configuration.Builder.setRUMResourceAttributesProvider(_:) | RUM.Configuration.urlSessionTracking.resourceAttributesProvider |
Datadog.Configuration.Builder.trackBackgroundEvents(_:) | RUM.Configuration.trackBackgroundEvents |
Datadog.Configuration.Builder.trackFrustrations(_:) | RUM.Configuration.frustrationsTracking |
Datadog.Configuration.Builder.set(mobileVitalsFrequency:) | RUM.Configuration.vitalsUpdateFrequency |
Datadog.Configuration.Builder.set(sampleTelemetry:) | RUM.Configuration.telemetrySampleRate |
クラッシュレポート
To enable Crash Reporting, make sure to enable RUM and Logs to report to those products respectively.
import DatadogCrashReporting
CrashReporting.enable()
1.x | 2.0 |
---|
Datadog.Configuration.Builder.enableCrashReporting() | CrashReporting.enable() |
WebView Tracking
To enable WebViewTracking, make sure to also enable RUM and Logs to report to those products respectively.
import WebKit
import DatadogWebViewTracking
let webView = WKWebView(...)
WebViewTracking.enable(webView: webView)
1.x | 2.0 |
---|
WKUserContentController.startTrackingDatadogEvents | WebViewTracking.enable(webView:) |
セッション リプレイ
For instructions on setting up Mobile Session Replay, see Mobile Session Replay Setup and Configuration.
No change in the SDK initialization is needed.
SDK Configuration Changes
Certain configuration properties have been moved or renamed to support modularity in Datadog’s native SDKs.
The following structures have been renamed:
1.x | 2.x |
---|
DdSdkConfiguration | DatadogConfiguration |
LoggingConfiguartion | DatadogLoggingConfiguration |
RumConfiguration | DatadogRumConfiguration |
DdSdkExistingConfiguration | DatadogAttachConfiguration |
The following properties have changed:
1.x | 2.x | 注 |
---|
DdSdkConfiguration.trackingConsent | 削除 | Part of Datadog.initialize |
DdSdkConfiguration.customEndpoint | 削除 | Now configured per-feature |
DdSdkConfiguration.serviceName | DatadogConfiguration.service | |
DdSdkConfiguration.logEventMapper | DatadogLoggingConfiguration.eventMapper | |
DdSdkConfiguration.customLogsEndpoint | DatadogLoggingConfiguration.customEndpoint | |
DdSdkConfiguration.telemetrySampleRate | DatadogRumConfiguration.telemetrySampleRate | |
In addition, the following APIs have changed:
1.x | 2.x | 注 |
---|
Verbosity | 削除 | See CoreLoggerLevel or LogLevel |
DdLogs DatadogSdk.logs | DatadogLogging DatadogSdk.logs | Type changed |
DdRum DatadogSdk.rum | DatadogRum DatadogSdk.rum | Type changed |
Verbosity DatadogSdk.sdkVerbosity | CoreLoggerLevel DatadogSdk.sdkVerbosity | |
DatadogSdk.runApp | DatadogSdk.runApp | Added trackingConsent parameter |
DatadogSdk.initialize | DatadogSdk.initialize | Added trackingConsent parameter |
DatadogSdk.createLogger | DatadogLogging.createLogger | Moved |
Flutter Web Changes
Clients using Flutter Web should update to using the Datadog Browser SDK v5. Change the following import in your index.html
:
- <script type="text/javascript" src="https://www.datadoghq-browser-agent.com/datadog-logs-v4.js"></script>
- <script type="text/javascript" src="https://www.datadoghq-browser-agent.com/datadog-rum-slim-v4.js"></script>
+ <script type="text/javascript" src="https://www.datadoghq-browser-agent.com/us1/v5/datadog-logs.js"></script>
+ <script type="text/javascript" src="https://www.datadoghq-browser-agent.com/us1/v5/datadog-rum-slim.js"></script>
Note: Datadog provides one CDN bundle per site. See the Browser SDK README for a list of all site URLs.
Logs product changes
As with v1, Datadog Logging can be enabled by setting the DatadogConfiguration.loggingConfiguration
member. However, unlike v1, Datadog does not create a default logger for you. DatadogSdk.logs
is now an instance of DatadogLogging
, which can be used to create logs. Many options were moved to DatadogLoggerConfiguration
to give developers more granular support over individual loggers.
The following APIs have changed:
1.x | 2.x | 注 |
---|
LoggingConfiguration | DatadogLoggingConfiguration | Renamed most members are now on DatadogLoggerConfiguration |
LoggingConfiguration.sendNetworkInfo | DatadogLoggerConfiguration.networkInfoEnabled | |
LoggingConfiguration.printLogsToConsole | DatadogLoggerConfiguration.customConsoleLogFunction | |
LoggingConfiguration.sendLogsToDatadog | Removed. Use remoteLogThreshold instead | |
LoggingConfiguration.datadogReportingThreshold | DatadogLoggerConfiguration.remoteLogThreshold | |
LoggingConfiguration.bundleWithRum | DatadogLoggerConfiguration.bundleWithRumEnabled | |
LoggingConfiguration.bundleWithTrace | DatadogLoggerConfiguration.bundleWithTraceEnabled | |
LoggingConfiguration.loggerName | DatadogLoggerConfiguration.name | |
LoggingConfiguration.sampleRate | DatadogLoggerConfiguration.remoteSampleRate | |
RUM Product Changes
The following APIs have changed:
1.x | 2.x | 注 |
---|
RumConfiguration | DatadogRumConfiguration | Type renamed |
RumConfiguration.vitalsUpdateFrequency | DatadogRumConfiguration.vitalsUpdateFrequency | Set to null to disable vitals updates |
RumConfiguration.tracingSampleRate | DatadogRumConfiguration.traceSampleRate | |
RumConfiguration.rumViewEventMapper | DatadogRumConfiguration.viewEventMapper | |
RumConfiguration.rumActionEventMapper | DatadogRumConfiguration.actionEventMapper | |
RumConfiguration.rumResourceEventMapper | DatadogRumConfiguration.resourceEventMapper | |
RumConfiguration.rumErrorEventMapper | DatadogRumConfiguration.rumErrorEventMapper | |
RumConfiguration.rumLongTaskEventMapper | DatadogRumConfiguration.longTaskEventMapper | |
RumUserActionType | RumActionType | Type renamed |
DdRum.addUserAction | DdRum.addAction | |
DdRum.startUserAction | DdRum.startAction | |
DdRum.stopUserAction | DdRum.stopAction | |
DdRum.startResourceLoading | DdRum.startResource | |
DdRum.stopResourceLoading | DdRum.stopResource | |
DdRum.stopResourceLoadingWithError | DdRum.stopResourceWithError | |
Additionally, event mappers no longer allow you to modify their view names. To rename a view, use a custom ViewInfoExtractor
instead.