All Products
Search
Document Center

Application Real-Time Monitoring Service:SDK configuration reference

Last Updated:Aug 12, 2025

ARMS Real User Monitoring (RUM) provides software development kit (SDK) configuration items that you can use to meet specific requirements. This topic describes common SDK configurations for PC applications.

Startup configuration

(Required) Set the Config address

Each application requires a corresponding configuration address. You must set the address before you call the alibabacloud_rum_init function.

void alibabacloud_rum_options_set_config_address(alibabacloud_rum_options_t *options, const char *config_address);

Parameter

Description

Constraints

Result on failure

options

alibabacloud_rum_options_t

Not empty. Create the struct by calling the alibabacloud_rum_options_new() function.

The function call fails and the SDK stops.

config_address

const char*

Not empty. Generated by the Real User Monitoring platform.

The function call fails and the SDK stops.

Example:

alibabacloud_rum_options_set_config_address(options, RUM_CONFIG_ADDRESS);

(Required) Set the application ID

Each application requires a corresponding application ID. You must set the application ID before you call the alibabacloud_rum_init function.

void alibabacloud_rum_options_set_app_id(alibabacloud_rum_options_t *options, const char *app_id)

Parameter

Description

Constraints

Result on failure

app_id

Application AppId

The unique application ID generated by the Real User Monitoring platform.

The function call fails and the SDK stops.

Example:

alibabacloud_rum_options_set_app_id(options, RUM_CONFIG_APPID);

(Required) Set the application version

You must set the application version number before you call the alibabacloud_rum_init function.

void alibabacloud_rum_options_set_app_version(alibabacloud_rum_options_t *options, const char *app_version)

Parameter

Description

Constraints

Result on failure

app_version

const char*

Not empty. The string length must be greater than 0 and less than 64.

The function call fails and the application version setting does not take effect.

Example:

alibabacloud_rum_options_set_app_version(options, "0.1.0-beta.2");

(Optional) Set the application environment

You can set the application environment, such as local, daily, pre, gray, or prod. You must call this function before you call the alibabacloud_rum_init function.

void alibabacloud_rum_options_set_env(alibabacloud_rum_options_t *options, alibabacloud_rum_env_t env)

Parameter

Description

Constraints

Result on failure

env

Application environment

Specify one of the following enumeration values:

  • ALIBABACLOUD_RUM_ENV_PROD

  • ALIBABACLOUD_RUM_ENV_GRAY

  • ALIBABACLOUD_RUM_ENV_PRE

  • ALIBABACLOUD_RUM_ENV_DAILY

  • ALIBABACLOUD_RUM_ENV_LOCAL

The function call fails and the application environment setting does not take effect.

Example:

alibabacloud_rum_options_set_env(options, ALIBABACLOUD_RUM_ENV_LOCAL);

(Optional) Set the device ID

The SDK generates a device ID by default and caches it to a local file. You can also set a custom device ID. You must call this function before you call the alibabacloud_rum_init function.

void alibabacloud_rum_options_set_utdid(alibabacloud_rum_options_t *options, const char *utdid)

Parameter

Description

Constraints

Result on failure

utdid

const char*, device ID.

Not empty. The string length must be greater than 0 and less than 37.

The function call fails and the device ID setting does not take effect.

Example:

alibabacloud_rum_options_set_utdid(options, "b7028408-ddac-4a58-72a9-653f6637f0e6");

(Optional) Set the log level

The SDK outputs logs at runtime. If you encounter issues when you use the SDK, you can adjust the log level to output more detailed information for troubleshooting. You must call this function before you call the alibabacloud_rum_init function.

void alibabacloud_rum_options_set_debug_level(alibabacloud_rum_options_t *options, alibabacloud_rum_level_t level);

Parameter

Description

Constraints

Result on failure

level

Log level.

Specify one of the following enumeration values:

  • ALIBABACLOUD_RUM_LEVEL_FATAL

  • ALIBABACLOUD_RUM_LEVEL_ERROR

  • ALIBABACLOUD_RUM_LEVEL_WARNING

  • ALIBABACLOUD_RUM_LEVEL_INFO

  • ALIBABACLOUD_RUM_LEVEL_DEBUG

  • ALIBABACLOUD_RUM_LEVEL_TRACE

  • ALIBABACLOUD_RUM_LEVEL_ALL

ALIBABACLOUD_RUM_LEVEL_ALL is the highest log level. At this level, logs are written to the cache file.

The function call fails and the log level setting does not take effect.

Example:

alibabacloud_rum_options_set_debug_level(options, ALIBABACLOUD_RUM_LEVEL_DEBUG);

(Optional) Set the cache directory

The SDK generates cache files at runtime. You can specify a custom cache directory. By default, the SDK creates a folder named .alibabacloud-rum in the same directory as the executable file. You must call this function before you call the alibabacloud_rum_init function.

void alibabacloud_rum_options_set_cache_path(alibabacloud_rum_options_t *options, const char *path)

Parameter

Description

Constraints

Result on failure

path

const char *

Not empty. The length of the file path may be limited by the operating system.

The function call fails and the cache directory setting does not take effect.

Example:

alibabacloud_rum_options_set_cache_path(options, "/path/to/your/cache/");

(Optional) Set the network request collection filter

The SDK supports collecting network request data from the libcurl and Chromium Embedded Framework (CEF) frames. You can configure a network request collection filter to control the collection behavior for specific URLs. You must call this function before you call the alibabacloud_rum_init function.

void alibabacloud_rum_options_set_network_options(alibabacloud_rum_options_t *options, alibabacloud_rum_network_options_t *network_options)

Parameter

Description

Constraints

Result on failure

network_options

Network request filter struct.

Not empty. Must conform to the following struct definition:

typedef struct alibabacloud_rum_network_options_s
{
    int (ALIBABACLOUD_RUM_CALLBACK *should_record_request)(const char *url);
    int (ALIBABACLOUD_RUM_CALLBACK *should_tracing)(const char *url);
} alibabacloud_rum_network_options_t;

The function call fails and the network request collection filter setting does not take effect.

Example:

// Filter whether to allow collection for a specific URL.
// If this function returns 0, data is not collected. If it returns a non-zero value, data is collected.
int ALIBABACLOUD_RUM_CALLBACK example_should_record_request(const char *url)
{
    LOG("example", "example_should_record_request, url: %s", url);
    return 1;
}

// Filter whether to allow end-to-end tracing for a specific URL.
// If this function returns 0, tracing is allowed. If it returns a non-zero value, tracing is not allowed.
int ALIBABACLOUD_RUM_CALLBACK example_should_tracing(const char *url)
{
    LOG("example", "example_should_tracing, url: %s", url);
    return NULL != strstr(url, "/api/data");
}

// Note: The SDK configures network_options by default. By default, request data for all URLs is collected, but end-to-end tracing is not allowed for any URL.
alibabacloud_rum_network_options_t *network_options = alibabacloud_rum_network_options_new();
network_options->should_tracing = example_should_tracing;
network_options->should_record_request = example_should_record_request;
alibabacloud_rum_options_set_network_options(options, network_options);

(Optional) Enable or disable the libcurl network data collection module

You can configure whether to enable the libcurl network data collection module. This module is enabled by default. You must call this function before you call the alibabacloud_rum_init function.

void alibabacloud_rum_options_set_auto_curl_tracking(alibabacloud_rum_options_t *options, int enabled)

Parameter

Description

Constraints

Result on failure

enabled

int

  • 0: Disable

  • 1: Enable

The function call fails and the libcurl network data collection module setting does not take effect.

Example:

// Enable the libcurl network data collection module.
alibabacloud_rum_options_set_auto_curl_tracking(options, 1);
Important

Before you enable the libcurl network data collection module, you must integrate the libcurl library. Currently, only data from the libcurl dynamic library can be collected.

(Optional) Enable or disable the crash collection module

You can configure whether to enable the crash data collection module. This module is enabled by default. You must call this function before you call the alibabacloud_rum_init function.

void alibabacloud_rum_options_set_auto_crash_tracking(alibabacloud_rum_options_t *options, int enabled)

Parameter

Description

Constraints

Result on failure

enabled

int

  • 0: Disable

  • 1: Enable

The function call fails and the crash data collection module setting does not take effect.

Example:

// Enable the crash data collection module.
alibabacloud_rum_options_set_auto_crash_tracking(options, 1);

(Optional) Enable or disable the CEF frame data collection module

You can configure whether to enable the CEF frame data collection module. This module is disabled by default. You must call this function before you call the alibabacloud_rum_init function.

void alibabacloud_rum_options_set_auto_cef_tracking(alibabacloud_rum_options_t *options, int enabled)

Parameter

Description

Constraints

Result on failure

enabled

int

  • 0: Disable

  • 1: Enable

The function call fails and the CEF frame data collection module setting does not take effect.

Example:

// Enable the CEF frame data collection module.
alibabacloud_rum_options_set_auto_cef_tracking(options, 1);
Important

Before you enable the CEF frame data collection module, you must integrate the CEF library. Currently, only data from the CEF dynamic library can be collected.

(Required) Start the SDK

Use the alibabacloud_rum_init function to initialize the SDK.

int alibabacloud_rum_init(alibabacloud_rum_options_t *options)

Parameter

Description

Constraints

Result on failure

options

SDK configuration items

Not empty. All required parameters must be set.

The function call fails and the SDK stops.

(Required) Shut down the SDK

Use the alibabacloud_rum_close function to shut down the SDK.

int alibabacloud_rum_close()

Example:

alibabacloud_rum_close()

Custom information

Set the username

You can set user-related information. This lets you associate data analytics with actual users. You must call this function after you call the alibabacloud_rum_init function.

void alibabacloud_rum_set_username(const char *username)

Parameter

Description

Constraints

Result on failure

username

const char *

The string cannot be empty and must have 256 or fewer characters.

The function call fails and the current setting is invalid.

Example:

alibabacloud_rum_set_username("my nick name is xxxx");

Set the user ID

You can use the SDK to set user information and associate data analytics with actual users. This function must be called after the alibabacloud_rum_init function.

void alibabacloud_rum_set_userid(const char *userid)

Parameter

Description

Constraints

Result on failure

userid

const char *

The string cannot be empty and must have 256 or fewer characters.

The function call fails and the current setting is invalid.

Example:

alibabacloud_rum_set_userid("1234567890");

Set user extension information

You can set user-related information. This lets you associate data analytics with actual users.

void alibabacloud_rum_set_user_tags(const char *user_tags)

Parameter

Description

Constraints

Result on failure

user_tags

const char*

The string cannot be empty and must have 512 or fewer characters.

The function call fails and the current setting is invalid.

Set global properties

You can set custom global business properties. After you set global properties, all newly generated data automatically includes this information. This lets you associate data analytics with business properties. Calling the alibabacloud_rum_set_properties function overwrites previous values.

#define alibabacloud_rum_set_properties(...)

Parameter

Description

Constraints

Result on failure

(...)

Property key-value pairs

The maximum number of key-value pairs is 50. The maximum length of a key is 52 characters. The total length of all key-value pair strings cannot exceed 2,000 characters.

The function call fails and the current setting is invalid.

Example:

alibabacloud_rum_set_properties("shop_id", "gz_xihu_001", "shop_name", "West Lake Main Store");

Report a custom exception

To collect statistics on custom exception data, you can call the custom exception function and pass the corresponding parameters. The C/C++ SDK provides a set of functions to report custom exceptions.

alibabacloud_rum_custom_exception_t* alibabacloud_rum_custom_exception_new(const char *name, const char *message);
void alibabacloud_rum_custom_exception_set_file(alibabacloud_rum_custom_exception_t *event, const char *file);
void alibabacloud_rum_custom_exception_set_source(alibabacloud_rum_custom_exception_t *event, const char *source);
void alibabacloud_rum_custom_exception_set_caused_by(alibabacloud_rum_custom_exception_t *event, const char *caused_by);
void alibabacloud_rum_custom_exception_set_stack(alibabacloud_rum_custom_exception_t *event, const char *stack);
void alibabacloud_rum_custom_exception_free(alibabacloud_rum_custom_exception_t *event);
void alibabacloud_rum_custom_exception_report(alibabacloud_rum_custom_exception_t *event);

Function name

Description

alibabacloud_rum_custom_exception_new

Creates an alibabacloud_rum_custom_exception_t instance.

alibabacloud_rum_custom_exception_set_file

Sets the source file associated with the exception.

alibabacloud_rum_custom_exception_set_source

Sets the exception source. This is a reserved field.

alibabacloud_rum_custom_exception_set_caused_by

Sets the cause of the exception.

alibabacloud_rum_custom_exception_set_stack

Sets the exception stack.

alibabacloud_rum_custom_exception_free

Releases the alibabacloud_rum_custom_exception_t instance. You do not usually need to call this function.

alibabacloud_rum_custom_exception_report

Reports the custom exception.

Example:

alibabacloud_rum_custom_exception_t *custom_exception = alibabacloud_rum_custom_exception_new("exception", "NullPointerException");
alibabacloud_rum_custom_exception_set_file(custom_exception, "/example/main.c");
alibabacloud_rum_custom_exception_set_caused_by(custom_exception, "NullPointerException");
alibabacloud_rum_custom_exception_set_stack(custom_exception, "Exception in thread 'main' java.util.NullPointerException");
alibabacloud_rum_custom_exception_report(custom_exception);

Report a custom event

To collect statistics on custom event data, you can call the corresponding function and pass the relevant parameters. The C/C++ SDK provides a set of functions to report custom events.

alibabacloud_rum_custom_event_t* alibabacloud_rum_custom_event_new(const char *type, const char *name);
void alibabacloud_rum_custom_event_set_value(alibabacloud_rum_custom_event_t *event, double value);
void alibabacloud_rum_custom_event_set_group(alibabacloud_rum_custom_event_t *event, const char *group);
void alibabacloud_rum_custom_event_set_snapshots(alibabacloud_rum_custom_event_t *event, const char *snapshots);
void alibabacloud_rum_custom_event_add_extra(alibabacloud_rum_custom_event_t *event, const char *k, const  char *v);
void alibabacloud_rum_custom_event_free(alibabacloud_rum_custom_event_t *event);
void alibabacloud_rum_custom_event_report(alibabacloud_rum_custom_event_t *event);

Function name

Description

alibabacloud_rum_custom_event_new

Creates an alibabacloud_rum_custom_event_t instance.

alibabacloud_rum_custom_event_set_value

Sets the value associated with the event.

alibabacloud_rum_custom_event_set_group

Sets the event group.

alibabacloud_rum_custom_event_set_snapshots

Sets the event snapshot.

alibabacloud_rum_custom_event_add_extra

Sets extension parameters for the event.

alibabacloud_rum_custom_event_free

Releases the alibabacloud_rum_custom_event_t instance. You do not usually need to call this function.

alibabacloud_rum_custom_event_report

Reports the custom event.

Example:

alibabacloud_rum_custom_event_t *event = alibabacloud_rum_custom_event_new("custom_event_type", "custom_event_name");
alibabacloud_rum_custom_event_set_group(event, "custom_event_group");
alibabacloud_rum_custom_event_set_value(event, 123.3456);
alibabacloud_rum_custom_event_set_snapshots(event, "custom event snapshots");
alibabacloud_rum_custom_event_add_extra(event, "event_key1", "event_value1");
alibabacloud_rum_custom_event_add_extra(event, "event_key2", "event_value2");
alibabacloud_rum_custom_event_report(event);

Report a custom log

To collect statistics on custom log data, you can call the corresponding function and pass the relevant parameters. The C/C++ SDK provides a set of functions to report custom logs.

alibabacloud_rum_custom_log_t *alibabacloud_rum_custom_log_new(const char *type, const char *name);
void alibabacloud_rum_custom_log_set_log(alibabacloud_rum_custom_log_t *log, alibabacloud_rum_custom_log_level_t level, const char *content);
void alibabacloud_rum_custom_log_set_value(alibabacloud_rum_custom_log_t *log, double value);
void alibabacloud_rum_custom_log_set_group(alibabacloud_rum_custom_log_t *log, const char *group);
void alibabacloud_rum_custom_log_set_snapshots(alibabacloud_rum_custom_log_t *log, const char *snapshots);
void alibabacloud_rum_custom_log_add_extra(alibabacloud_rum_custom_log_t *log, const char *k, const char *v);
void alibabacloud_rum_custom_log_free(alibabacloud_rum_custom_log_t *log);
void alibabacloud_rum_custom_log_report(alibabacloud_rum_custom_log_t *log);

Function name

Description

alibabacloud_rum_custom_log_t

Creates an alibabacloud_rum_custom_log_t instance.

alibabacloud_rum_custom_log_set_log

Sets the log content.

alibabacloud_rum_custom_log_set_value

Sets the value associated with the log.

alibabacloud_rum_custom_log_set_group

Sets the log group.

alibabacloud_rum_custom_log_set_snapshots

Sets the log snapshot.

alibabacloud_rum_custom_log_add_extra

Sets extension parameters for the log.

alibabacloud_rum_custom_log_free

Releases the alibabacloud_rum_custom_log_t instance. You do not usually need to call this function.

alibabacloud_rum_custom_log_report

Reports the custom log.

Example:

alibabacloud_rum_custom_log_t *log = alibabacloud_rum_custom_log_new("custom_log_type", "custom_log_name");
alibabacloud_rum_custom_log_set_group(log, "custom_log_group");
alibabacloud_rum_custom_log_set_value(log, 343.4222);
alibabacloud_rum_custom_log_set_snapshots(log, "custom log snapshots");
alibabacloud_rum_custom_log_set_log(log, LOG_DEBUG, "This is the custom log content");
alibabacloud_rum_custom_log_add_extra(log, "log_key1", "log_value1");
alibabacloud_rum_custom_log_add_extra(log, "log_key2", "log_value2");
alibabacloud_rum_custom_log_report(log);