- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
If you have not set up the SDK yet, follow the in-app setup instructions or refer to the Kotlin Multiplatform RUM setup documentation.
Kotlin Multiplatform RUM automatically tracks attributes such as user activity, screens, errors, and network requests. See the RUM Data Collection documentation to learn about the RUM events and default attributes. You can further enrich user session information and gain finer control over the attributes collected by tracking custom events.
In addition to tracking views automatically, you can also track specific distinct views (such as activities and fragments) manually. Stop tracking when the view is no longer visible.
// to start view
GlobalRumMonitor.get().startView(viewKey, viewName, viewAttributes)
// to stop view
GlobalRumMonitor.get().stopView(viewKey, viewAttributes)
In addition to RUM’s default attributes, you can measure where your application is spending its time by using the addTiming
API. The timing measure is relative to the start of the current RUM view. For example, you can time how long it takes for your hero image to appear:
fun onHeroImageLoaded() {
GlobalRumMonitor.get().addTiming("hero_image")
}
Once the timing is sent, the timing is accessible as @view.custom_timings.<timing_name>
. For example: @view.custom_timings.hero_image
. You must create a measure before graphing it in RUM analytics or in dashboards.
In addition to tracking actions automatically, you can also track specific custom user actions (such as taps, clicks, and scrolls) with RumMonitor#addAction
. For continuous action tracking (for example, tracking a user scrolling a list), use RumMonitor#startAction
and RumMonitor#stopAction
.
The action type should be one of the following: “custom”, “click”, “tap”, “scroll”, “swipe”, “back”.
fun onUserInteraction() {
GlobalRumMonitor.get().addAction(actionType, name, actionAttributes)
}
In addition to tracking resources automatically, you can also track specific custom resources (such as network requests and third-party provider APIs) with methods (such as GET
and POST
) while loading the resource with RumMonitor#startResource
. Stop tracking with RumMonitor#stopResource
when it is fully loaded, or RumMonitor#stopResourceWithError
if an error occurs while loading the resource.
fun loadResource() {
GlobalRumMonitor.get().startResource(resourceKey, method, url, resourceAttributes)
try {
// do load the resource
GlobalRumMonitor.get().stopResource(resourceKey, resourceKind, additionalAttributes)
} catch (e: Exception) {
GlobalRumMonitor.get().stopResourceWithError(resourceKey, message, origin, e)
}
}
Note: stopResource
/ stopResourceWithError
methods accepting NSURLConnection
and NSError
are also available from iOS source set.
To track specific errors, notify the monitor when an error occurs with the message, source, exception, and additional attributes. Refer to the Attributes collected documentation.
GlobalRumMonitor.get().addError(message, source, throwable, attributes)
Note: addError
method accepting NSError
is also available from iOS source set.
You can use the addUserExtraInfo
API to append extra user properties to previously set properties.
Datadog.addUserExtraInfo(extraInfo)
The Kotlin Multiplatform SDK first stores events. It only uploads these events when the intake specification conditions are met.
You have the option of deleting all unsent data stored by the SDK with the clearAllData
API.
Datadog.clearAllData()
You can use the stopInstance
API to stop the SDK instance from collecting and uploading data further.
Datadog.stopInstance()
You can define the minimum log level (priority) to send events to Datadog in a logger instance. If the log priority is below the one you set at this threshold, it does not get sent. The default value is to allow all.
val logger = Logger.Builder()
.setRemoteLogThreshold(LogLevel.INFO)
.build()
In addition to the default RUM attributes captured by the RUM Kotlin Multiplatform SDK automatically, you can choose to add additional contextual information, such as custom attributes, to your RUM events to enrich your observability within Datadog. Custom attributes allow you to filter and group information about observed user behavior (such as cart value, merchant tier, or ad campaign) with code-level information (such as backend services, session timeline, error logs, and network health).
Adding user information to your RUM sessions helps you to:
The following attributes are optional, but you should provide at least one of them:
Attribute | Type | Description |
---|---|---|
usr.id | String | Unique user identifier. |
usr.name | String | User friendly name, displayed by default in the RUM UI. |
usr.email | String | User email, displayed in the RUM UI if the user name is not present. It is also used to fetch Gravatars. |
To identify user sessions, use the setUserInfo
API, for example:
Datadog.setUserInfo('1234', 'John Doe', 'john@doe.com')
// Adds an attribute to all future RUM events
GlobalRumMonitor.get().addAttribute(key, value)
// Removes an attribute to all future RUM events
GlobalRumMonitor.get().removeAttribute(key)
You can use the following methods in Configuration.Builder
when creating the Datadog configuration to initialize the library:
useSite(DatadogSite)
setBatchSize([SMALL|MEDIUM|LARGE])
setUploadFrequency([FREQUENT|AVERAGE|RARE])
setBatchProcessingLevel(LOW|MEDIUM|HIGH)
trackCrashes(Boolean)
true
.You can use the following methods in RumConfiguration.Builder
when creating the RUM configuration to enable RUM features:
trackLongTasks(durationThreshold)
durationThreshold
on the main thread as long tasks in Datadog. See Automatically track long tasks for more information.setVitalsUpdateFrequency([FREQUENT|AVERAGE|RARE|NEVER])
setSessionSampleRate(<sampleRate>)
setSessionListener(RumSessionListener)
setTelemetrySampleRate
0
and 100
. By default, this is set to 20
.setViewEventMapper
setResourceEventMapper
setActionEventMapper
setErrorEventMapper
setLongTaskEventMapper
trackBackgroundEvents
trackFrustrations
These methods can be accessed only from Android source set.
trackNonFatalAnrs(Boolean)
trackUserInteractions(Array<ViewAttributesProvider>)
useViewTrackingStrategy(strategy)
trackUiKitViews(UIKitRUMViewsPredicate)
UIViewController
s as RUM views. See Automatically track views for more information.trackUiKitActions(UIKitRUMActionsPredicate)
UITouch
events as RUM actions. The predicate implementation should return RUM action parameters if the given interaction should be accepted, or null
to ignore it. By default, all touches are accepted.setAppHangThreshold(Long)
To automatically track your views (such as activities and fragments), provide a tracking strategy at initialization. Depending on your application’s architecture, you can choose one of the following strategies:
ActivityViewTrackingStrategy
FragmentViewTrackingStrategy
MixedViewTrackingStrategy
NavigationViewTrackingStrategy
For instance, to set each fragment as a distinct view, use the following configuration in your setup:
// in common source set
val rumConfig = RumConfiguration.Builder(applicationId)
.apply {
platformSpecificSetup(this)
}
.build()
internal expect fun platformSpecificSetup(
rumConfigurationBuilder: RumConfiguration.Builder
)
// in Android source set
internal actual fun platformSpecificSetup(
rumConfigurationBuilder: RumConfiguration.Builder
) {
rumConfigurationBuilder.useViewTrackingStrategy(
FragmentViewTrackingStrategy(...)
)
}
For ActivityViewTrackingStrategy
, FragmentViewTrackingStrategy
, or MixedViewTrackingStrategy
, you can filter which Fragment
or Activity
is tracked as a RUM View by providing a ComponentPredicate
implementation in the constructor:
val strategy = ActivityViewTrackingStrategy(
trackExtras = true,
componentPredicate = object : ComponentPredicate<Activity> {
override fun accept(component: Activity): Boolean {
return true
}
override fun getViewName(component: Activity): String? = null
})
Note: By default, the library is using ActivityViewTrackingStrategy
. If you decide not to provide a view tracking strategy, you must manually send the views by calling the startView
and stopView
methods yourself.
To automatically track views (UIViewController
s), use the trackUiKitViews
method when enabling RUM. By default, views are named with the view controller’s class name. To customize it, provide your own implementation of the uiKitViewsPredicate
that conforms to UIKitRUMViewsPredicate
interface.
Inside the createView(viewController: UIViewController)
implementation, your app should decide if a given UIViewController
instance should start the RUM view (return value) or not (return null
). The returned RUMView
value must specify the name
and may provide additional attributes
for the created RUM view.
For instance, you can configure the predicate to use explicit type check for each view controller in your app:
class YourCustomPredicate: UIKitRUMViewsPredicate {
override fun createView(viewController: UIViewController): RUMView? {
return when (viewController) {
is HomeViewController -> RUMView("Home)
is DetailsViewController -> RUMView("Details")
else -> null
}
}
}
You can even come up with a more dynamic solution depending on your app’s architecture.
Note: By default, UIKit view tracking is not enabled.
Long running operations performed on the main thread can impact the visual performance and reactivity of your application. To track these operations, define the duration threshold above which a task is considered too long.
val rumConfig = RumConfiguration.Builder(applicationId)
// …
.trackLongTasks(durationThreshold)
.build()
For example, to replace the default 100 ms
duration, set a custom threshold in your configuration.
val rumConfig = RumConfiguration.Builder(applicationId)
// …
.trackLongTasks(250L) // track tasks longer than 250ms as long tasks
.build()
To modify some attributes in your RUM events, or to drop some of the events entirely before batching, provide an implementation of EventMapper<T>
when initializing the RUM Kotlin Multiplatform SDK:
val rumConfig = RumConfiguration.Builder(applicationId)
// ...
.setErrorEventMapper(rumErrorEventMapper)
.setActionEventMapper(rumActionEventMapper)
.setResourceEventMapper(rumResourceEventMapper)
.setViewEventMapper(rumViewEventMapper)
.setLongTaskEventMapper(rumLongTaskEventMapper)
.build()
When implementing the EventMapper<T>
interface, only some attributes are modifiable for each event type:
Event type | Attribute key | Description |
---|---|---|
ViewEvent | view.referrer | URL that linked to the initial view of the page. |
view.url | URL of the view. | |
view.name | Name of the view. | |
ActionEvent | action.target.name | Target name. |
view.referrer | URL that linked to the initial view of the page. | |
view.url | URL of the view. | |
view.name | Name of the view. | |
ErrorEvent | error.message | Error message. |
error.stack | Stacktrace of the error. | |
error.resource.url | URL of the resource. | |
view.referrer | URL that linked to the initial view of the page. | |
view.url | URL of the view. | |
view.name | Name of the view. | |
ResourceEvent | resource.url | URL of the resource. |
view.referrer | URL that linked to the initial view of the page. | |
view.url | URL of the view. | |
view.name | Name of the view. | |
LongTaskEvent | view.referrer | URL that linked to the initial view of the page. |
view.url | URL of the view. | |
view.name | Name of the view. |
Note: If you return null from the EventMapper<T>
implementation, the event is dropped.
Retrieving the RUM session ID can be helpful for troubleshooting. For example, you can attach the session ID to support requests, emails, or bug reports so that your support team can later find the user session in Datadog.
You can access the RUM session ID at runtime without waiting for the sessionStarted
event:
GlobalRumMonitor.get().getCurrentSessionId { sessionId ->
currentSessionId = sessionId
}