tencent cloud

Tencent Cloud Observability Platform

API Description

Download
Focus Mode
Font Size
Last updated: 2026-05-25 18:01:56
This article describes the feature APIs of the Terminal Performance Monitoring Pro (RUM Pro) SDK to facilitate flexible and in-depth integration.

Initialization APIs

During SDK initialization, in addition to setting appId and appKey, you can also configure various user parameters in BuglyConfig.
/// Sets a custom version number.
@property (nonatomic, copy) NSString *appVersion;
/// Sets a custom device unique identifier.
@property (nonatomic, copy) NSString *deviceIdentifier;
/// Sets a custom user ID.
@property (nonatomic, copy) NSString *userIdentifier;
/// Sets build config to fetch different configurations.
@property (nonatomic, assign) BuglyBuildConfig buildConfig;

/// Bugly Delegate
@property (nonatomic, assign) id<BuglyDelegate> delegate;


Callback APIs

Setting the Crash Attachment Callback

SDK trigger a callback to your business logic when handling a crash. You can add custom logic in the callback or provide additional information to be reported along with the exception.
/// Allows you to attach data to case reports.
/// param eventType Case event type
/// @param customData Business custom fields
/// @param eventInfo Case information (currently empty)
- (NSDictionary<NSString *, NSString *> *)attachmentForEvent:(NSString *)eventType
customData:(BuglyCustomData *)customData
eventInfo:(NSDictionary *)eventInfo;

#### 2. Callback for setting crash information

Bugly trigger a callback to your business logic when reporting a crash. You can add custom logic in the callback.

``` objective-c
/**
* Callback when an exception occurs
* @param exception Exception information
* @return The record to be reported along with the exception
*/
- (NSString * __nullable)attachmentForException:(NSException * __nullable)exception;

Setting the Log Callback

1. Implement a function callback method.
/// Custom log function
static void logger_func(RMLoggerLevel level, const char *log) {
//handle sdk log.
}
2. Then register the method.
// Registers Bugly log output.
[Bugly registerLogCallback:logger_func];

Other APIs

You need to call other APIs after SDK initialization. Calls made before the initialization are invalid. The SDK provides the following additional APIs.

Updating the Device ID

/**
* Updates device ID.
* @param deviceId Device ID
*/
+ (void)updateDeviceIdentifier:(NSString *)deviceId;

Updating the User ID

/**
* Updates userId.
* @param userId User ID
*/
+ (void)updateUserIdentifier:(NSString *)userId;

Obtaining the SDK Version Number

/**
* Gets SDK version information.
* @return SDK version number
*/
+ (NSString *)sdkVersion;

Reporting a Custom Exception

If you need to report errors other than OC/C++ exceptions, such as C# or JavaScript exceptions, you can use the custom exception API to report them to RUM Pro. The reported data is displayed on the Error page.
/**
* @brief Reports a custom error.
*
* @param category Type (Cocoa=3, CSharp=4, JS=5, Lua=6)
* @param aName Name
* @param aReason Error reason
* @param aStackArray Stack trace
* @param info Additional data
* @param terminate Whether to terminate the app process after reporting
*/
+ (void)reportExceptionWithCategory:(NSUInteger)category
name:(NSString *)aName
reason:(NSString *)aReason
callStack:(NSArray *)aStackArray
extraInfo:(NSDictionary *)info
terminateApp:(BOOL)terminate;

Reporting a Custom Error

If you want to report NSError information to RUM Pro, you can use the error reporting API. The reported data is displayed on the Error page.
/**
* Reports an error.
*
* @param error Error information
*/
+ (void)reportError:(NSError *)error;

Reporting an OC Exception

If you catches an exception using try-catch and wants to report it to RUM Pro, you can use the exception reporting API. The reported data is displayed on the Error page.
/**
* Reports a custom Objective-C exception.
*
* @param exception Exception information
*/
+ (void)reportException:(NSException *)exception;

Setting a Case Tag

/**
* Updates case tags. This must be called after Bugly SDK initialization (in the Bugly setup completeHandler callback); otherwise, data loss may occur.
* SDK version: 2.7.53.3+
* @params tagArr String array (max length: 30, each string max length: 1024 bytes)
*/
+ (void)updateCaseTags:(NSArray<NSString *> *)tagArr;

Setting Business Drill-Down

/**
* Update business drill-down. This must be called after Bugly SDK initialization (the Bugly setup completeHandler callback); otherwise, data loss may occur.
* SDK version: 2.7.53.3+
* @params tagArr String array (max length: 30, each string max length: 1024 bytes)
*/
+ (void)updateTestTags:(NSArray<NSString *> *)tagArr;

Custom Data

Adding Custom Data (Crash Monitoring)

RUM Pro allows you to add custom data to save custom environment information at the time of a crash or before it occurs. The custom data is reported along with the exception and displayed in the Custom Fields section on the exception case details page. You can add a maximum of 50 key-value pairs as custom data.
/**
* Sets key data to be reported along with crash information.
*
* @param value KEY
* @param key VALUE
*/
+ (void)setUserValue:(NSString *)value forKey:(NSString *)key;
To retrieve the custom data you have set, use the following API.
/**
* Gets custom data.
*
* @return Key data
*/
+ (NSDictionary * _Nullable)allUserValues;

Setting and Updating a Custom File Upload Path (Crash Monitoring)

RUM Pro allows you to upload custom large files and associate them with exception cases. Custom file uploads use a separate channel from exception reporting, ensuring no interference with the exception handling process. Multiple files can be configured. You can configure and update the array of file paths via the following API at any time before an exception occurs. After the process restarts due to an exception, the custom files will be reported and displayed as custom_log.zip in the attachments to the exception case.
/**
* Sets a collection of absolute paths for custom attachments.
* The compressed file must not exceed 10 MB and will be uploaded on the next startup.
*/
+ (void)setAdditionalAttachmentPaths:(NSArray<NSString *>*)pathArray;
Note:
This API allows a maximum of 10 file paths.
The compressed file must not exceed 10 MB. Files exceeding this limit will not be uploaded.
This API can be called multiple times. Updated file paths will overwrite the previous values.
Custom files are uploaded on the next startup, which introduces a delay relative to exception reporting.
Frequent crashes may trigger file cleanup logic, potentially causing missed file uploads.
You can configure the sampling rate for custom file uploads. For details, see SDK Configuration.
Calling this API when a crash occurs will not take effect. You need to set the file paths in advance.

Activating and Deactivating a Custom Scenario (Performance Monitoring)

In performance monitoring, you can customize scenarios and execute specific monitoring or callback operations based on these scenarios. You can use the following APIs to activate and reset custom scenarios.
Set a Custom Scenario
/// Updates scenario information.
/// @param key Scenario ID. Features such as lag, memory, and resource monitoring will cluster data based on this value.
+ (void)setScene:(NSString *)key;
Reset a Custom Scenario
/// Ends the custom scenario and resumes using the scenario information automatically captured by RMonitor.
+ (void)resetScene;

Adding and Removing a Custom Data Collector (Performance Monitoring)

The custom settings for the performance monitoring module in RUM Pro differ from those in the crash monitoring module. The performance monitoring module supports two types of custom data: custom dimensions and custom fields.
Custom dimensions: Three sets of keys are predefined by the SDK (see BuglyCustomData.h for details), with 10 keys per set. You can select appropriate keys to report data as needed. In the console, you can assign aliases to these keys for easier viewing and analysis. For custom dimensions, the server stores each field separately, enabling advanced query and analysis capabilities in the future. Currently, both global settings and pre-reporting callbacks are supported.
Custom fields: Keys and values are freely defined by you. The SDK does not interpret the field types and stores all values as strings. In the console, you can search for reports containing specific content using these custom fields in the issue list and issue details pages.
Note:
Global settings mean you can call the global setting API at any time to configure custom dimensions. For the same key, repeated calls update the existing value. When performance data is ready to be reported, the globally cached custom dimension data is retrieved.
Use the following API to get the default callback for collecting global custom dimensions, and then set the dimensions through this callback.
/**
* Adds custom tags. Calling this before SDK initialization has no effect.
* @param data Custom fields to be updated
*/
+ (void)updateCustomData:(BuglyCustomData *)data;

/**
* Gets a copy of the current custom tags. Returns empty if not set.
* @return Configured custom fields
*/
+ (nullable BuglyCustomData *)currentCustomData;

/**
* Adds custom data for specific event reporting.
* @param data Custom fields to be updated
* @param eventType The corresponding event type
*/
+ (void)updateCustomData:(BuglyCustomData *)data forEvent:(BuglyEventTypeName)eventType;

/**
* Gets custom data for a specific event.
* @param eventType The event type to get
* @return The corresponding configured custom fields
*/
+ (nullable BuglyCustomData *)currentCustomDataForEvent:(BuglyEventTypeName)eventType;

/**
* Updates this custom data with new custom fields.
* @param dict Dictionary information conforming to the BuglyCustomData storage format
* @return The updated data
*/
- (BuglyCustomData *)customDataByUpdateDict:(NSDictionary *)dict;

/**
*Gets numeric custom data.
* @param key If the key is not defined in NumberParamKey, returns 0.0 immediately.
* @return The current value if set; otherwise, 0.0.
*/
- (nullable NSNumber *)getNumberParam:(BuglyCustomNumberDataKey)key;

/**
* Sets numeric custom data.
* @param key If the key is not defined in NumberParamKey, adding fails.
* @param param NUMBER VALUE
*/
- (BOOL)putNumberParam:(nullable NSNumber *)param forKey:(BuglyCustomNumberDataKey)key;

/**
* Gets string custom data.
* @param key If the key is not defined in StringParamKey, returns "" immediately.
* @return The current value if set; otherwise, "".
*/
- (nullable NSString *)getStringParam:(BuglyCustomStringDataKey)key;

/**
* Sets string custom data.
* @param key If the key is not defined in StringParamKey, adding fails.
* @param param The length must not exceed BUGLY_CUSTOM_DATA_MAX_STRING_VALUE_LENGTH.
* If value = null, it will be set to an empty string.
* If value exceeds the length limit, it will be truncated to the first BUGLY_CUSTOM_DATA_MAX_STRING_VALUE_LENGTH characters.
*/
- (BOOL)putStringParam:(nullable NSString *)param forKey:(BuglyCustomStringDataKey)key;

/**
* Gets string array custom data.
* @param key If the key is not defined in StringArrayParamKey, returns an empty list immediately.
* @return The current value if set; otherwise, an empty list. The returned list cannot be modified.
*/
- (nullable NSArray<NSString *> *)getStringArrayParam:(BuglyCustomArrayDataKey)key;

/**
* The addition sequence is: A1 -> A2 -> A2 -> A3 -> A4. This API produces a result similar to: [A1, A2, A3, A4].
* Adds VALUE to string array custom data.
* @param key If the key is not defined in StringArrayParamKey, adding fails.
* @param param A non-null, non-empty string. If the value does not exist, it will be added; if it exists, returns immediately. The length must not exceed BUGLY_CUSTOM_DATA_MAX_STRING_VALUE_LENGTH.
*/
- (BOOL)addStringToStringArrayParam:(NSString *)param forKey:(BuglyCustomArrayDataKey)key;

/**
* Removes VALUE from string array custom data.
* @param key If the key is not defined in StringArrayParamKey, removal fails.
* @param param If the value exists, it will be removed; if it does not exist, returns immediately.
*/
- (BOOL)removeStringFromStringArrayParam:(NSString *)param forKey:(BuglyCustomArrayDataKey)key;

/**
* The addition sequence is: A1 -> A2 -> A2 -> A3 -> A4. This API produces a result similar to: [A1, A2, A2, A3, A4].
* Adds VALUE to string array custom data.
* @param key If the key is not defined in StringArrayParamKey, adding fails.
* @param param The length must not exceed BUGLY_CUSTOM_DATA_MAX_STRING_VALUE_LENGTH. The value is added regardless of whether it exists, allowing duplicates.
* @return Returns failure if the value is null, empty, exceeds the length limit, or the array has reached its maximum size; otherwise, returns success.
*/
- (BOOL)addStringToSequence:(NSString *)param forKey:(BuglyCustomArrayDataKey)key;


Startup Monitoring

Definition

The cold start duration calculation differs between iOS versions before 15 and iOS 15 and later.
iOS versions prior to 15: Cold start duration = First frame rendering time – App process creation time
iOS 15 and later:
Apple introduced Prewarming in iOS 15, which can pre-launch processes. This makes the period from "App process initialization end time" to "main function execution time" highly unpredictable. Therefore, this uncertain interval is excluded from the cold start duration calculation, which is adjusted as follows: Cold start duration = First frame rendering time – main function execution time + App process initialization end time – App process creation time

API Overview

Custom Scenario Duration Statistics

Call + (void)startSpan:(NSString *)spanName parentSpanName:(nullable NSString *)parentSpanName of BuglyLaunchMonitorPlugin to record the start timestamp of a custom scenario.
[BuglyLaunchMonitorPlugin startSpan:@"testSpan" parentSpanName:nil];
Call + (void)endSpan:(NSString *)spanName of BuglyLaunchMonitorPlugin to mark the end of a custom scenario interval. Ensure the spanName matches the one used when starting the span; otherwise, the data will be considered invalid.
[BuglyLaunchMonitorPlugin endSpan:@"testSpan"];
Call + (void)endSpanFromLaunch:(NSString *)spanName of BuglyLaunchMonitorPlugin to record the duration of a span measured from process creation.
[BuglyLaunchMonitorPlugin endSpanFromLaunch:@"testSpan"];

Setting Startup Tags

Call - (void)addTag:(NSString *)tagName of BuglyLaunchMonitorPlugin to add a tag.
Call - (void)removeTag:(NSString *)tagName of BuglyLaunchMonitorPlugin to remove a tag.
[BuglyLaunchMonitorPlugin addTag:@"tagTest1"];
[BuglyLaunchMonitorPlugin removeTag:@"tagTest1"];

Customizing Launch End Time

For business-specific reasons, the point at which startup is considered complete may not align with the end of CA::Transaction::commit. Therefore, the - (void)endColdLaunch API is added for you to actively call and declare that the cold start has ended. Calling this API will trigger startup data reporting, and subsequent updates to tags or span information will not take effect.
If the API is not called, startup data reporting will still be triggered when the app is backgrounded, crashes, or after a certain timeout period (default: 3 minutes).
[BuglyLaunchMonitorPlugin endColdLaunch];




Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback