이 페이지는 아직 한국어로 제공되지 않으며 번역 작업 중입니다. 번역에 관한 질문이나 의견이 있으시면 언제든지 저희에게 연락해 주십시오.

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.

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)

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)

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

Additional helpful documentation, links, and articles: