Package 

Interface RumMonitor


  • 
    public interface RumMonitor
    
                        

    A 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 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.

        Parameters:
        key - the instance that represents the active view (usually your Activity or Fragment instance).
        name - the name of the view (usually your Activity or Fragment full class name)
        attributes - additional custom attributes to attach to the view.
      • stopView

         abstract Unit stopView(Object key, Map<String, Object> attributes)

        Stops a previously started View, linked with the key instance.

        Parameters:
        key - the instance that represents the active view (usually your Activity or Fragment instance).
        attributes - additional custom attributes to attach to the view.
      • 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 type
        name - the action identifier
        attributes - 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 type
        name - the action identifier
        attributes - 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

         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 loaded
        attributes - 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 bytes
        kind - the type of resource loaded
        attributes - 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 error
        source - the source of the error
        throwable - the throwable
        attributes - 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 error
        source - the source of the error
        stackTrace - the error stacktrace
        errorType - 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 error
        source - the source of the error
        throwable - the throwable
        attributes - 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 error
        source - the source of the error
        stacktrace - the error stacktrace information
        attributes - 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 flag
        value - 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)
      • clearAttributes

         abstract Unit clearAttributes()

        Clear all the global attributes added to this monitor.

      • addViewLoadingTime

         abstract Unit addViewLoadingTime(Boolean overwrite)

        Adds view loading time to the 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 - controls if the method overwrites the previously calculated view loading time.
      • addViewAttributes

         abstract Unit addViewAttributes(Map<String, Object> attributes)

        Adds attributes to the current active View. They will be propagated to all future RUM events within this View until it stops being active.

        Parameters:
        attributes - the attributes to add to the view
      • removeViewAttributes

         abstract Unit removeViewAttributes(Collection<String> attributes)

        Removes attributes from the current active View. Future RUM events within this view won't be having these attributes anymore.

        Parameters:
        attributes - the attribute keys to remove from the view
      • startFeatureOperation

         abstract Unit startFeatureOperation(String name, String operationKey, Map<String, Object> attributes)

        Starts the name feature operation.

        Parameters:
        name - the name of the operation.
        operationKey - optional operation key.
        attributes - additional custom attributes to attach to the feature operation.
      • succeedFeatureOperation

         abstract Unit succeedFeatureOperation(String name, String operationKey, Map<String, Object> attributes)

        Finishes the name feature operation with successful status.

        Parameters:
        name - the name of the operation.
        operationKey - optional operation key identifying a specific operation instance from the list of feature operations of the same name.
        attributes - additional custom attributes to attach to the feature operation.
      • failFeatureOperation

         abstract Unit failFeatureOperation(String name, String operationKey, FailureReason failureReason, Map<String, Object> attributes)

        Finishes the name feature operation with failure status.

        Parameters:
        name - the name of the operation.
        operationKey - optional operation key identifying a specific operation instance from the list of feature operations of the same name.
        failureReason - the reason for the operation failure.
        attributes - additional custom attributes to attach to the feature operation.
      • 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.