-
public interface RumMonitorA class enabling Datadog RUM features.
It allows you to record User events that can be explored and analyzed in Datadog Dashboards.
You can only have one active RumMonitor, and should retrieve it from the GlobalRumMonitor object.
-
-
Method Summary
Modifier and Type Method Description abstract UnitgetCurrentSessionId(Function1<String, Unit> callback)Get the current active session ID. abstract UnitstartView(Object key, String name, Map<String, Object> attributes)Notifies that a View is being shown to the user, linked with the key instance. abstract UnitstopView(Object key, Map<String, Object> attributes)Stops a previously started View, linked with the key instance. abstract UnitaddAction(RumActionType type, String name, Map<String, Object> attributes)Notifies that an action happened. abstract UnitstartAction(RumActionType type, String name, Map<String, Object> attributes)Notifies that an action started. abstract UnitstopAction(RumActionType type, String name, Map<String, Object> attributes)Notifies that an action stopped, and update the action's type and name. abstract UnitstartResource(String key, String method, String url, Map<String, Object> attributes)Notify that a new Resource is being loaded, linked with the key instance. abstract UnitstartResource(String key, RumResourceMethod method, String url, Map<String, Object> attributes)Notify that a new Resource is being loaded, linked with the key instance. abstract UnitstopResource(String key, Integer statusCode, Long size, RumResourceKind kind, Map<String, Object> attributes)Stops a previously started Resource, linked with the key instance. abstract UnitstopResourceWithError(String key, Integer statusCode, String message, RumErrorSource source, Throwable throwable, Map<String, Object> attributes)Stops a previously started Resource that failed loading, linked with the key instance. abstract UnitstopResourceWithError(String key, Integer statusCode, String message, RumErrorSource source, String stackTrace, String errorType, Map<String, Object> attributes)Stops a previously started Resource that failed loading, linked with the key instance by providing the intercepted stacktrace. abstract UnitaddError(String message, RumErrorSource source, Throwable throwable, Map<String, Object> attributes)Notifies that an error occurred in the active View. abstract UnitaddErrorWithStacktrace(String message, RumErrorSource source, String stacktrace, Map<String, Object> attributes)Notifies that an error occurred in the active View. abstract UnitaddTiming(String name)Adds a specific timing in the active View. abstract UnitaddFeatureFlagEvaluation(String name, Object value)Adds result of evaluating a feature flag to the view. abstract UnitaddFeatureFlagEvaluations(Map<String, Object> featureFlags)Adds result of evaluating a set of feature flag to the view. abstract UnitaddAttribute(String key, Object value)Adds a global attribute to all future RUM events. abstract UnitremoveAttribute(String key)Removes a global attribute from all future RUM events. abstract Map<String, Object>getAttributes()abstract UnitclearAttributes()Clear all the global attributes added to this monitor. abstract UnitstopSession()Stops the current session. abstract UnitaddViewLoadingTime(Boolean overwrite)Adds view loading time RUM active view based on the time elapsed since the view was started. abstract BooleangetDebug()Utility setting to inspect the active RUM View. abstract UnitsetDebug(Boolean debug)Utility setting to inspect the active RUM View. -
-
Method Detail
-
getCurrentSessionId
abstract Unit getCurrentSessionId(Function1<String, Unit> callback)
Get the current active session ID. The session ID will be null if no session is active or if the session has been sampled out.
This method uses an asynchronous callback to ensure all pending RUM events have been processed up to the moment of the call.
- Parameters:
callback- the callback to be invoked with the current session id.
-
startView
abstract Unit startView(Object key, String name, Map<String, Object> attributes)
Notifies that a View is being shown to the user, linked with the key instance.
-
stopView
abstract Unit stopView(Object key, Map<String, Object> attributes)
Stops a previously started View, linked with the key instance.
-
addAction
abstract Unit addAction(RumActionType type, String name, Map<String, Object> attributes)
Notifies that an action happened. This is used to track discrete actions (e.g.: tap).
- Parameters:
type- the action typename- the action identifierattributes- additional custom attributes to attach to the action.
-
startAction
abstract Unit startAction(RumActionType type, String name, Map<String, Object> attributes)
Notifies that an action started. This is used to track long running actions (e.g.: scroll). Such an action must be stopped with stopAction, and will be stopped automatically if it lasts more than 10 seconds.
- Parameters:
type- the action typename- the action identifierattributes- additional custom attributes to attach to the action.
-
stopAction
abstract Unit stopAction(RumActionType type, String name, Map<String, Object> attributes)
Notifies that an action stopped, and update the action's type and name. This is used to stop tracking long running actions (e.g.: scroll), started with startAction.
- Parameters:
type- the action type (overriding the last started action)name- the action identifier (overriding the last started action)attributes- additional custom attributes to attach to the action.
-
startResource
@Deprecated(message = This method is deprecated and will be removed in the future versions. Use `startResource` method which takes `RumHttpMethod` as `method` parameter instead.) abstract Unit startResource(String key, String method, String url, Map<String, Object> attributes)
Notify that a new Resource is being loaded, linked with the key instance.
- Parameters:
key- the instance that represents the resource being loaded (usually your request or network call instance).method- the method used to load the resource (E.g.url- the url or local path of the resource being loadedattributes- additional custom attributes to attach to the resource.
-
startResource
abstract Unit startResource(String key, RumResourceMethod method, String url, Map<String, Object> attributes)
Notify that a new Resource is being loaded, linked with the key instance.
- Parameters:
key- the instance that represents the resource being loaded (usually your request or network call instance).method- the method used to load the resource (E.g.url- the url or local path of the resource being loadedattributes- additional custom attributes to attach to the resource.
-
stopResource
abstract Unit stopResource(String key, Integer statusCode, Long size, RumResourceKind kind, Map<String, Object> attributes)
Stops a previously started Resource, linked with the key instance.
- Parameters:
key- the instance that represents the active view (usually your request or network call instance).statusCode- the status code of the resource (if any)size- the size of the resource, in byteskind- the type of resource loadedattributes- additional custom attributes to attach to the resource.
-
stopResourceWithError
abstract Unit stopResourceWithError(String key, Integer statusCode, String message, RumErrorSource source, Throwable throwable, Map<String, Object> attributes)
Stops a previously started Resource that failed loading, linked with the key instance.
- Parameters:
key- the instance that represents the active view (usually your request or network call instance).statusCode- the status code of the resource (if any)message- a message explaining the errorsource- the source of the errorthrowable- the throwableattributes- additional custom attributes to attach to the error.
-
stopResourceWithError
abstract Unit stopResourceWithError(String key, Integer statusCode, String message, RumErrorSource source, String stackTrace, String errorType, Map<String, Object> attributes)
Stops a previously started Resource that failed loading, linked with the key instance by providing the intercepted stacktrace. Note: This method should only be used from hybrid application.
- Parameters:
key- the instance that represents the active view (usually your request or network call instance).statusCode- the status code of the resource (if any)message- a message explaining the errorsource- the source of the errorstackTrace- the error stacktraceerrorType- the type of the error.attributes- additional custom attributes to attach to the error.
-
addError
abstract Unit addError(String message, RumErrorSource source, Throwable throwable, Map<String, Object> attributes)
Notifies that an error occurred in the active View.
- Parameters:
message- a message explaining the errorsource- the source of the errorthrowable- the throwableattributes- additional custom attributes to attach to the error.
-
addErrorWithStacktrace
abstract Unit addErrorWithStacktrace(String message, RumErrorSource source, String stacktrace, Map<String, Object> attributes)
Notifies that an error occurred in the active View.
This method is meant for non-native or cross platform frameworks (such as React Native or Flutter) to send error information to Datadog. Although it can be used directly, it is recommended to pass a Throwable instead.
- Parameters:
message- a message explaining the errorsource- the source of the errorstacktrace- the error stacktrace informationattributes- additional custom attributes to attach to the error.
-
addTiming
abstract Unit addTiming(String name)
Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.
- Parameters:
name- the name of the new custom timing attribute.
-
addFeatureFlagEvaluation
abstract Unit addFeatureFlagEvaluation(String name, Object value)
Adds result of evaluating a feature flag to the view. Feature flag evaluations are local to the active view and are cleared when the view is stopped. If you need to submit more than one feature flag evaluation at the same time, consider using the addFeatureFlagEvaluations method instead.
- Parameters:
name- the name of the feature flagvalue- the value the feature flag evaluated to
-
addFeatureFlagEvaluations
abstract Unit addFeatureFlagEvaluations(Map<String, Object> featureFlags)
Adds result of evaluating a set of feature flag to the view. Feature flag evaluations are local to the active view and are cleared when the view is stopped.
- Parameters:
featureFlags- the map of feature flags
-
addAttribute
abstract Unit addAttribute(String key, Object value)
Adds a global attribute to all future RUM events.
- Parameters:
key- the attribute key (non null)value- the attribute value (or null)
-
removeAttribute
abstract Unit removeAttribute(String key)
Removes a global attribute from all future RUM events.
- Parameters:
key- the attribute key (non null)
-
getAttributes
abstract Map<String, Object> getAttributes()
-
clearAttributes
abstract Unit clearAttributes()
Clear all the global attributes added to this monitor.
-
stopSession
abstract Unit stopSession()
Stops the current session. A new session will start in response to a call to
startView,addAction, orstartAction. If the session is started because of a call toaddAction, orstartAction, the last know view is restarted in the new session.
-
addViewLoadingTime
abstract Unit addViewLoadingTime(Boolean overwrite)
Adds view loading time RUM active view based on the time elapsed since the view was started. The view loading time is automatically calculated as the difference between the current time and the start time of the view. This method should be called only once per view. If no view is started or active, this method does nothing.
- Parameters:
overwrite- which controls if the method overwrites the previously calculated view loading time.
-
getDebug
abstract Boolean getDebug()
Utility setting to inspect the active RUM View. If set, a debugging outline will be displayed on top of the application, describing the name of the active RUM View in the default SDK instance (if any). May be used to debug issues with RUM instrumentation in your app.
Default value is
false.
-
setDebug
abstract Unit setDebug(Boolean debug)
Utility setting to inspect the active RUM View. If set, a debugging outline will be displayed on top of the application, describing the name of the active RUM View in the default SDK instance (if any). May be used to debug issues with RUM instrumentation in your app.
Default value is
false.
-
-
-
-