このページは日本語には対応しておりません。随時翻訳に取り組んでいます。翻訳に関してご質問やご意見ございましたら、お気軽にご連絡ください。

Overview

In order to use multiple instances of the SDK, you will need to adopt version 2.0.0 or higher. See the Upgrade RUM Mobile SDKs guide.

Follow this guide to use multiple named instances of the SDK. Many methods of the SDK optionally take an SDK instance as an argument. If none is provided, the call is associated with the default (nameless) SDK instance.

Note: The SDK instance name should be consistent between application runs. Storage paths for SDK events depend on this.

Note: Session Replay can only run on a single core at once. To switch to a different one, first stop the existing core it is running on.

val namedSdkInstance = Datadog.initialize("myInstance", context, configuration, trackingConsent)

val userInfo = UserInfo(...)
Datadog.setUserInfo(userInfo, sdkCore = namedSdkInstance)

Logs.enable(logsConfig, namedSdkInstance)
val logger = Logger.Builder(namedSdkInstance)
    ...
    .build()

Trace.enable(traceConfig, namedSdkInstance)
val tracer = AndroidTracer.Builder(namedSdkInstance)
    ...
    .build()

Rum.enable(rumConfig, namedSdkInstance)
GlobalRumMonitor.get(namedSdkInstance)

NdkCrashReports.enable(namedSdkInstance)

WebViewTracking.enable(webView, allowedHosts, namedSdkInstance)

SessionReplay.enable(sessionReplayConfig, namedSdkInstance)

Note: In order for instrumentation to work on the WebView component, it is very important that the JavaScript is enabled on the WebView. To enable it, you can use the following code snippet:

    webView.settings.javaScriptEnabled = true

You can retrieve the named SDK instance by calling Datadog.getInstance(<name>) and use the Datadog.isInitialized(<name>) method to check if the particular SDK instance is initialized.

import DatadogCore
import DatadogRUM
import DatadogLogs
import DatadogTrace

let core = Datadog.initialize(
    with: configuration, 
    trackingConsent: trackingConsent, 
    instanceName: "my-instance"
)

RUM.enable(
    with: RUM.Configuration(applicationID: "<RUM Application ID>"),
    in: core
)

Logs.enable(in: core)

Trace.enable(in: core)

SessionReplay.enable(with: sessionReplayConfig, in: core)

Once the named SDK instance is initialized, you can retrieve it by calling Datadog.sdkInstance(named: "<name>") and use it as shown below.

import DatadogCore

let core = Datadog.sdkInstance(named: "my-instance")

Logs

import DatadogLogs

let logger = Logger.create(in: core)

Trace

import DatadogRUM

let monitor = RUMMonitor.shared(in: core)

RUM

import DatadogRUM

let monitor = RUMMonitor.shared(in: core)

Further Reading

お役に立つドキュメント、リンクや記事:

PREVIEWING: rtrieu/product-analytics-ui-changes