RUM iOS Monitoring

RUM iOS Monitoring

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

Datadog Real User Monitoring (RUM) enables you to visualize and analyze the real-time performance and user journeys of your application’s individual users.

Setup

  1. Declare the SDK as a dependency.
  2. Specify application details in the UI.
  3. Initialize the library.
  4. Initialize the RUM Monitor, DDURLSessionDelegate, and start sending data.

Note: The minimum supported version for the Datadog iOS SDK is iOS v11+.

Declare SDK as dependency

  1. Declare dd-sdk-ios as a dependency, depending on your package manager.
Package managerInstallation method
CocoaPodspod 'DatadogSDK'
Swift Package Manager.package(url: "https://github.com/DataDog/dd-sdk-ios.git", .upToNextMajor(from: "1.0.0"))
Carthagegithub "DataDog/dd-sdk-ios"

Specify application details in UI

  1. In UX Monitoring > RUM Applications, click New Application.
  2. Select iOS as your Application Type in the Datadog UI and provide a new application name to generate a unique Datadog application ID and client token.

To keep your data safe, do not use a Datadog API key to configure the dd-sdk-ios library. Instead, use the client token to prevent your API key from being publicly exposed on the client side in the iOS application byte code.

For more information about setting up a client token, see the Client token documentation.

Initialize the library

Datadog.initialize(
    appContext: .init(),
    trackingConsent: trackingConsent,
    configuration: Datadog.Configuration
        .builderUsing(
            rumApplicationID: "<rum_application_id>",
            clientToken: "<client_token>",
            environment: "<environment_name>"
        )
        .set(serviceName: "app-name")
        .trackUIKitRUMViews()
        .trackUIKitActions()
        .trackURLSession()
        .build()
)
Datadog.initialize(
    appContext: .init(),
    trackingConsent: trackingConsent,
    configuration: Datadog.Configuration
        .builderUsing(
            rumApplicationID: "<rum_application_id>",
            clientToken: "<client_token>",
            environment: "<environment_name>"
        )
        .set(serviceName: "app-name")
        .set(endpoint: .eu)
        .trackUIKitRUMViews()
        .trackUIKitActions()
        .trackURLSession()
        .build()
)

The RUM SDK automatically tracks user sessions depending on options provided at the SDK initialization. To add GDPR compliance for your EU users and other initialization parameters to the SDK configuration, see the Set tracking consent documentation.

Initialize RUM Monitor and DDURLSessionDelegate

Configure and register the RUM Monitor. You only need to do it once, usually in your AppDelegate code:

import Datadog

Global.rum = RUMMonitor.initialize()

To monitor requests sent from the URLSession instance as resources, assign DDURLSessionDelegate() as a delegate of that URLSession:

let session = URLSession(
    configuration: .default,
    delegate: DDURLSessionDelegate(),
    delegateQueue: nil
)

Further Reading

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