Skip to content

RUM Configuration

RUM Initialization Configuration

FTSdk.initRUMWithConfig(
        new FTRUMConfig()
            .setRumAppId(RUM_APP_ID)
            .setEnableTraceUserView(true)
            .setDeviceMetricsMonitorType(DeviceMetricsMonitorType.ALL.getValue())
            .setEnableTraceUserAction(true)
            .setEnableTraceUserResource(true)
            .setEnableTrackAppUIBlock(true)
            .setEnableTrackAppCrash(true)
            .setEnableTrackAppANR(true)
            .setExtraMonitorTypeWithError(ErrorMonitorType.ALL.getValue())
);
FTSdk.initRUMWithConfig(
    FTRUMConfig()
        .setRumAppId(RUM_APP_ID)
        .setEnableTraceUserView(true)
        .setDeviceMetricsMonitorType(DeviceMetricsMonitorType.ALL.getValue())
        .setEnableTraceUserAction(true)
        .setEnableTraceUserResource(true)
        .setEnableTrackAppUIBlock(true)
        .setEnableTrackAppCrash(true)
        .setEnableTrackAppANR(true)
        .setExtraMonitorTypeWithError(ErrorMonitorType.ALL.getValue())
)
Method Name Type Required Description
setRumAppId String Yes Set the Rum AppId. Corresponds to setting the RUM appid, which enables RUM collection. How to get appid
setSamplingRate Float No Set the sampling rate. Value range [0,1], 0 means no collection, 1 means full collection, default is 1. Scope applies to all View, Action, LongTask, Error data under the same session_id.
setSessionErrorSampleRate Float No Set the error sampling rate. When a session is not sampled by setSamplingRate, if an error occurs during the session, data from the 1 minute before the error can be collected. Value range [0,1], 0 means no collection, 1 means full collection, default is 0. Scope applies to all View, Action, LongTask, Error data under the same session_id. Supported in ft-sdk 1.6.11 and above.
setEnableTrackAppCrash Boolean No Whether to report App crash logs. Default is false. When enabled, error stack data will be displayed in error analysis. For issues with obfuscated content conversion in crash logs, refer to Symbol File Upload. In ft-sdk 1.5.1 and above, extraLogCatWithJavaCrash and extraLogCatWithNativeCrash can be used to control whether logcat is displayed for Java Crash and Native Crash.
setExtraMonitorTypeWithError Array No Set auxiliary monitoring information, adding additional monitoring data to RUM crash data. ErrorMonitorType.BATTERY for battery level, ErrorMonitorType.MEMORY for memory usage, ErrorMonitorType.CPU for CPU usage. Not set by default.
setDeviceMetricsMonitorType Array No Set View monitoring information, adding monitoring data during the View lifecycle. DeviceMetricsMonitorType.BATTERY monitors the maximum current output of the current page, DeviceMetricsMonitorType.MEMORY monitors the memory usage of the current application, DeviceMetricsMonitorType.CPU monitors CPU jumps, DeviceMetricsMonitorType.FPS monitors screen frame rate. Monitoring period options: DetectFrequency.DEFAULT 500 ms, DetectFrequency.FREQUENT 100 ms, DetectFrequency.RARE 1 second. Not set by default.
setEnableTrackAppANR Boolean No Whether to enable ANR detection. Default is false. In ft-sdk 1.5.1 and above, extraLogCatWithANR can be used to control whether logcat is displayed for ANR.
setEnableTrackAppUIBlock Boolean, long No Whether to enable UI blocking detection. Default is false. In ft-sdk 1.6.4 and above, blockDurationMs can be used to control the detection time range [100,), unit milliseconds, default is 1 second.
setEnableTraceUserAction Boolean No Whether to automatically trace user operations. Currently only supports user launch and click operations. This configuration depends on ft-plugin. Default is false.
setEnableTraceUserView Boolean No Whether to automatically trace user page operations. This configuration depends on ft-plugin. Default is false.
setEnableTraceUserViewInFragment Boolean No Whether to automatically trace Fragment type page data. This configuration depends on ft-plugin. Default is false. Supported in ft-sdk 1.6.11 and above.
setEnableTraceUserResource Boolean No Whether to automatically trace user network requests. This configuration depends on ft-plugin, only supports OkHttp. Default is false.
setEnableResourceHostIP Boolean No Whether to collect the IP address of the requested target domain. Scope: Only affects default collection when EnableTraceUserResource is true. For custom Resource collection, use FTResourceEventListener.FTFactory(true) to enable this function. Also, a single OkHttp has an IP caching mechanism for the same domain. Under the same OkHttpClient, if the server IP does not change, it will only be generated once.
setResourceUrlHandler Callback No Set conditions for filtering Resources. No filtering by default.
setOkHttpEventListenerHandler Callback No ASM sets global OkHttp EventListener. Not set by default.
setOkHttpResourceContentHandler Callback No ASM sets global FTResourceInterceptor.ContentHandlerHelper. Not set by default. Supported in ft-sdk 1.6.7 and above. Custom Resource
addGlobalContext Dictionary No Add custom tags for distinguishing user monitoring data sources. If tracking functionality is needed, the parameter key should be track_id, value can be any value. For rules and precautions on adding, refer to here.
setRumCacheLimitCount int No Local cache RUM limit count [10_000,), default is 100_000. Supported in ft-sdk 1.6.6 and above.
setEnableTraceWebView Boolean No Whether to enable WebView data collection via Android SDK. Default is true. Supported in ft-sdk 1.6.12 and above.
setAllowWebViewHost Array No Set allowed WebView host addresses for data tracking. null means collect all. Default is null. Supported in ft-sdk 1.6.12 and above.
setViewActivityTrackingHandler FTViewActivityTrackingHandler No Used to customize the tracking method for Activity views. When an Activity lifecycle event occurs, this handler is called to decide how to track the Activity. No processing by default. Supported in ft-sdk 1.6.13 and above.
setViewFragmentTrackingHandler FTViewFragmentTrackingHandler No Used to customize the tracking method for Fragment views. When a Fragment lifecycle event occurs, this handler is called to decide how to track the Fragment. No processing by default. Supported in ft-sdk 1.6.13 and above.
setActionTrackingHandler FTActionTrackingHandler No Used to customize the tracking method for user operations. When a user performs an operation, this handler is called to decide how to track the operation. No processing by default. Supported in ft-sdk 1.6.13 and above.

RUM Manual Instrumentation

Configure enableTraceUserAction, enableTraceUserView, enableTraceUserResource, setEnableTrackAppUIBlock, setEnableTrackAppCrash, and setEnableTrackAppANR in FTRUMConfig to achieve automatic collection of Action, View, Resource, LongTask, and Error. For custom collection, use FTRUMGlobalManager for manual reporting.

Action

Usage

/**
 * Add Action
 *
 * @param actionName action name
 * @param actionType action type
 * @param property   additional property parameters (optional)
 */
public void startAction(String actionName, String actionType, HashMap<String, Object> property)

/**
 * Add Action. This type of data cannot be associated with Error, Resource, LongTask data.
 *
 * @param actionName action name
 * @param actionType action type
 * @param duration   nanoseconds, duration (optional)
 * @param property   extended properties (optional)
 */
public void addAction(String actionName, String actionType, long duration, HashMap<String, Object> property)
/**
 * Add action
 *
 * @param actionName action name
 * @param actionType action type
 * @param property   additional property parameters (optional)
 */
fun startAction(actionName: String, actionType: String, property: HashMap<String, Any>)

/**
 * Add Action
 *
 * @param actionName action name
 * @param actionType action type
 * @param duration   nanoseconds, duration (optional)
 * @param property   extended properties (optional)
 */
fun addAction(actionName: String, actionType: String, duration: Long, property: HashMap<String, Any>)

startAction has an internal duration calculation algorithm. During calculation, it attempts to associate data with nearby Resource, LongTask, Error data. It has a 100 ms frequent trigger protection. Recommended for user operation type data. If frequent calls are needed, use addAction. This data will not conflict with startAction and will not be associated with current Resource, LongTask, Error data.

Code Examples

// Scenario 1
FTRUMGlobalManager.get().startAction("login", "action_type");

// Scenario 2: Dynamic parameters
HashMap<String, Object> map = new HashMap<>();
map.put("ft_key", "ft_value");
FTRUMGlobalManager.get().startAction("login", "action_type", map);

// Scenario 1
FTRUMGlobalManager.get().addAction("login", "action_type");

// Scenario 2: Dynamic parameters
HashMap<String, Object> map = new HashMap<>();
map.put("ft_key", "ft_value");
FTRUMGlobalManager.get().addAction("login", "action_type", map);
// Scenario 1
FTRUMGlobalManager.get().startAction("login", "action_type")

// Scenario 2: Dynamic parameters
val map = HashMap<String, Any>()
map["ft_key"] = "ft_value"
FTRUMGlobalManager.get().startAction("login", "action_type", map)

// Scenario 1
FTRUMGlobalManager.get().addAction("login", "action_type")

// Scenario 2: Dynamic parameters
val map = HashMap<String, Any>()
map["ft_key"] = "ft_value"
FTRUMGlobalManager.get().addAction("login", "action_type", map)

View

Usage

/**
 * view start
 *
 * @param viewName current page name
 * @param property additional property parameters (optional)
 */
public void startView(String viewName, HashMap<String, Object> property)

/**
 * view end
 *
 * @param property additional property parameters (optional)
 */
public void stopView(HashMap<String, Object> property)

/**
 * Update the current view loading_time metric, unit nanoseconds
 *
 * @param duration duration
 */
public void updateLoadTime(long duration)
/**
 * view start
 *
 * @param viewName current page name
 * @param property additional property parameters (optional)
 */
fun startView(viewName: String, property: HashMap<String, Any>)

/**
 * view end
 *
 * @param property additional property parameters (optional)
 */
fun stopView(property: HashMap<String, Any>)

/**
 * Update the current view loading_time metric, unit nanoseconds
 *
 * @param duration duration
 */
fun updateLoadTime(duration: Long)

Code Examples

@Override
protected void onResume() {
    super.onResume();

    // Scenario 1
    FTRUMGlobalManager.get().startView("Current Page Name");

    // Scenario 2: Dynamic parameters
    HashMap<String, Object> map = new HashMap<>();
    map.put("ft_key", "ft_value");
    map.put("ft_key_will_change", "ft_value");
    FTRUMGlobalManager.get().startView("Current Page Name", map)
}

@Override
protected void onPause() {
    super.onPause();

    // Scenario 1
    FTRUMGlobalManager.get().stopView();

    // Scenario 2 : Dynamic parameters
    HashMap<String, Object> map = new HashMap<>();
    map.put("ft_key_will_change", "ft_value_change"); // The value of ft_key_will_change will be updated to ft_value_change when stopView is called.
    FTRUMGlobalManager.get().stopView(map);

}
override fun onResume() {
    super.onResume()

    // Scenario 1
    FTRUMGlobalManager.get().startView("Current Page Name")

    // Scenario 2: Dynamic parameters
    val map = HashMap<String, Any>()
    map["ft_key"] = "ft_value"
    map["ft_key_will_change"] = "ft_value"
    FTRUMGlobalManager.get().startView("Current Page Name", map)
}

override fun onPause() {
    super.onPause()

    // Scenario 1
    FTRUMGlobalManager.get().stopView()

    // Scenario 2 : Dynamic parameters
    val map = HashMap<String, Any>()
    map["ft_key_will_change"] = "ft_value_change" // The value of ft_key_will_change will be updated to ft_value_change when stopView is called.
    FTRUMGlobalManager.get().stopView(map)
}

Error

Usage

/**
 * Add error information
 *
 * @param log       log
 * @param message   message
 * @param errorType error type, ErrorType
 * @param state     program running state
 * @param dateline  occurrence time, nanoseconds (optional)
 * @param property  additional properties (optional)
 */
public void addError(String log, String message, long dateline, ErrorType errorType,
                     AppState state, HashMap<String, Object> property)

/**
 * Add error information
 *
 * @param log       log
 * @param message   message
 * @param errorType error type, String
 * @param state     program running state
 * @param dateline  occurrence time, nanoseconds (optional)
 * @param property  additional properties (optional)
 */
public void addError(String log, String message, long dateline, String errorType,
                     AppState state, HashMap<String, Object> property)
/**
 * Add error information
 *
 * @param log       log
 * @param message   message
 * @param errorType error type, ErrorType
 * @param state     program running state
 * @param dateline  occurrence time, nanoseconds (optional)
 * @param property  additional properties (optional)
 */
fun addError(log: String, message: String, dateline: Long, errorType: ErrorType, state: AppState, property: HashMap<String, Any>)

/**
 * Add error information
 *
 * @param log       log
 * @param message   message
 * @param errorType error type, String
 * @param state     program running state
 * @param dateline  occurrence time, nanoseconds (optional)
 * @param property  additional properties (optional)
 */
fun addError(log: String, message: String, dateline: Long, errorType: String, state: AppState, property: HashMap<String, Any>)

Code Examples

// Scenario 1:
FTRUMGlobalManager.get().addError("error log", "error msg", ErrorType.JAVA, AppState.RUN);

// Scenario 2: Record an error that occurred earlier. The time here is usually the time the error occurred.
FTRUMGlobalManager.get().addError("error log", "error msg", 16789000000000000000L, ErrorType.JAVA, AppState.RUN);

// Scenario 3: Dynamic parameters
HashMap<String, Object> map = new HashMap<>();
map.put("ft_key", "ft_value");
FTRUMGlobalManager.get().addError("error log", "error msg", ErrorType.JAVA, AppState.RUN, map);
// Scenario 1:
FTRUMGlobalManager.get().addError("error log", "error msg", ErrorType.JAVA, AppState.RUN)

// Scenario 2: Record an error that occurred earlier. The time here is usually the time the error occurred.
FTRUMGlobalManager.get().addError("error log", "error msg", 16789000000000000000, ErrorType.JAVA, AppState.RUN)

// Scenario 3: Dynamic parameters
val map = HashMap<String, Any>()
map["ft_key"] = "ft_value"
FTRUMGlobalManager.get().addError("error log", "error msg", ErrorType.JAVA, AppState.RUN, map)

LongTask

Usage

/**
 * Add long task
 *
 * @param log      log content
 * @param duration duration, nanoseconds
 * @param property additional property parameters (optional)
 */
public void addLongTask(String log, long duration, HashMap<String, Object> property)
/**
 * Add long task
 *
 * @param log      log content
 * @param duration duration, nanoseconds
 * @param property additional property parameters (optional)
 */
fun addLongTask(log: String, duration: Long, property: HashMap<String, Any>)

Code Examples

// Scenario 1
FTRUMGlobalManager.get().addLongTask("error log", 1000000L);

// Scenario 2: Dynamic parameters
HashMap<String, Object> map = new HashMap<>();
map.put("ft_key", "ft_value");
FTRUMGlobalManager.get().addLongTask("", 1000000L, map);
// Scenario 1
FTRUMGlobalManager.get().addLongTask("error log", 1000000L)

// Scenario 2: Dynamic parameters
val map = HashMap<String, Any>()
map["ft_key"] = "ft_value"
FTRUMGlobalManager.get().addLongTask("", 1000000L, map)

Resource

Usage

/**
 * resource start
 *
 * @param resourceId resource Id
 * @param property   additional property parameters (optional)
 */
public void startResource(String resourceId, HashMap<String, Object> property)

/**
 * resource end
 *
 * @param resourceId resource Id
 * @param property   additional property parameters (optional)
 */
public void stopResource(final String resourceId, HashMap<String, Object> property)

/**
 * Set network transmission content
 *
 * @param resourceId resourceId
 * @param params params
 * @param netStatusBean netStatusBean
 */
public void addResource(String resourceId, ResourceParams params, NetStatusBean netStatusBean)
/**
 * resource start
 *
 * @param resourceId resource Id (optional)
 */
fun startResource(resourceId: String, property: HashMap<String, Any>)

/**
 * resource end
 *
 * @param resourceId resource Id
 * @param property   additional property parameters (optional)
 */
fun stopResource(resourceId: String, property: HashMap<String, Any>)

/**
 * Set network transmission content
 *
 * @param resourceId resourceId
 * @param params params
 * @param netStatusBean netStatusBean
 */
fun addResource(resourceId: String, params: ResourceParams, netStatusBean: NetStatusBean)

Code Examples

// Scenario 1
// Request start
FTRUMGlobalManager.get().startResource("resourceId");

// ...

// Request end
FTRUMGlobalManager.get().stopResource("resourceId");

// Finally, after the request ends, send request-related data metrics
ResourceParams params = new ResourceParams();
params.setUrl("https://truewatch.com");
params.setResponseContentType(response.header("Content-Type"));
params.setResponseConnection(response.header("Connection"));
params.setResponseContentEncoding(response.header("Content-Encoding"));
params.setResponseHeader(response.headers().toString());
params.setRequestHeader(request.headers().toString());
params.setResourceStatus(response.code());
params.setResourceMethod(request.method());

NetStatusBean bean = new NetStatusBean();
bean.setTcpStartTime(60000000);
// ...

FTRUMGlobalManager.get().addResource("resourceId", params, bean);

// Scenario 2: Dynamic parameter usage
HashMap<String, Object> map = new HashMap<>();
map.put("ft_key", "ft_value");
map.put("ft_key_will_change", "ft_value");

FTRUMGlobalManager.get().startResource("resourceId", map);

// ...
HashMap<String, Object> map = new HashMap<>();
map.put("ft_key_will_change", "ft_value_change"); // The value of ft_key_will_change will be updated to ft_value_change when stopResource is called.
FTRUMGlobalManager.get().stopResource(uuid, map);
// Scenario 1
// Request start
FTRUMGlobalManager.get().startResource("resourceId")

// Request end
FTRUMGlobalManager.get().stopResource("resourceId")

// Finally, after the request ends, send request-related data metrics
val params = ResourceParams()
params.url = "https://truewatch.com"
params.responseContentType = response.header("Content-Type")
params.responseConnection = response.header("Connection")
params.responseContentEncoding = response.header("Content-Encoding")
params.responseHeader = response.headers.toString()
params.requestHeader = request.headers.toString()
params.resourceStatus = response.code
params.resourceMethod = request.method

val bean = NetStatusBean()
bean.tcpStartTime = 60000000
// ...
FTRUMGlobalManager.get().addResource("resourceId", params, bean)

// Scenario 2: Dynamic parameter usage
val map = hashMapOf<String, Any>(
    "ft_key" to "ft_value",
    "ft_key_will_change" to "ft_value"
)
FTRUMGlobalManager.get().startResource("resourceId", map)

// ...
val map = hashMapOf<String, Any>(
    "ft_key_will_change" to "ft_value_change"
)
// The value of ft_key_will_change will be updated to ft_value_change when stopResource is called.

FTRUMGlobalManager.get().stopResource(uuid, map)
Method Name Required Description Notes
NetStatusBean.fetchStartTime No Request start time
NetStatusBean.tcpStartTime No tcp connection time
NetStatusBean.tcpEndTime No tcp end time
NetStatusBean.dnsStartTime No dns start time
NetStatusBean.dnsEndTime No dns end time
NetStatusBean.responseStartTime No Response start time
NetStatusBean.responseEndTime No Response end time
NetStatusBean.sslStartTime No ssl start time
NetStatusBean.sslEndTime No ssl end time
NetStatusBean.property No Additional properties
ResourceParams.url Yes url address
ResourceParams.requestHeader No Request header parameters
ResourceParams.responseHeader No Response header parameters
ResourceParams.responseConnection No Response connection
ResourceParams.responseContentType No Response ContentType
ResourceParams.responseContentEncoding No Response ContentEncoding
ResourceParams.resourceMethod No Request method GET, POST, etc.
ResourceParams.responseBody No Response body content
ResourceParams.property No Additional properties

User Information Binding and Unbinding

Use FTSdk for user binding and unbinding.

Usage

/**
 * Bind user information
 *
 * @param id user ID
 */
public static void bindRumUserData(@NonNull String id)

/**
 * Bind user information
 */
public static void bindRumUserData(@NonNull UserData data)

/**
 * Unbind user information
 */
public static void unbindRumUserData()
/**
 * Bind user information
 *
 * @param id user ID
 */
fun bindRumUserData(id: String)

/**
 * Bind user information
 *
 * @param data user information
 */
fun bindRumUserData(data: UserData)

/**
 * Unbind user information
 */
fun unbindRumUserData()

UserData

Method Name Description Required Notes
setId Set user ID No
setName Set username No
setEmail Set email No
setExts Set user extensions No For adding rules, refer to Application Access

Code Examples

// This method can be called after successful user login to bind user information.
FTSdk.bindRumUserData("001");

UserData userData = new UserData();
userData.setName("test.user");
userData.setId("test.id");
userData.setEmail("[email protected]");
Map<String, String> extMap = new HashMap<>();
extMap.put("ft_key", "ft_value");
userData.setExts(extMap);
FTSdk.bindRumUserData(userData);

// This method can be called after user logout to unbind user information.
FTSdk.unbindRumUserData();
// This method can be called after successful user login to bind user information.
FTSdk.bindRumUserData("001")

// Bind more user data
val userData = UserData()
userData.name = "test.user"
userData.id = "test.id"
userData.email = "[email protected]"
val extMap = HashMap<String, String>()
extMap["ft_key"] = "ft_value"
userData.setExts(extMap)
FTSdk.bindRumUserData(userData)

// This method can be called after user logout to unbind user information.
FTSdk.unbindRumUserData()