All Products
Search
Document Center

CloudMonitor:SDK configuration reference

Last Updated:Sep 28, 2025

Cloud Monitor 2.0 provides several software development kit (SDK) configuration items that you can set to meet specific requirements. This topic describes the common SDK configurations for PC applications.

Startup

(Required) Address

You must configure an address for the app 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

Limit

Failure

options

alibabacloud_rum_options_t

Create a structure with SDK configurations by calling the alibabacloud_rum_options_new() function. The parameter is not empty.

The request fails, and the configuration does not take effect.

config_address

const char*

The address generated by RUM to which monitoring data is reported. The parameter is not empty.

The request fails, and the configuration does not take effect.

Example:

alibabacloud_rum_options_set_config_address(options, RUM_CONFIG_ADDRESS);

(Required) App ID

You must configure an ID for the app 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

Limit

Failure

app_id

App ID

Enter the unique app ID generated by RUM.

The request fails, and the configuration does not take effect.

Example:

alibabacloud_rum_options_set_app_id(options, RUM_CONFIG_APPID);

(Required) App name

You must configure the name of the app before you call the alibabacloud_rum_init function.

void alibabacloud_rum_options_set_app_name(alibabacloud_rum_options_t *options, const char *app_name)

Parameter

Description

Limit

Failure

app_name

App name in the const char* format

Specify a string with less than 128 characters. The parameter is not empty.

The request fails, and the configuration does not take effect.

Example:

alibabacloud_rum_options_set_app_name(options, "WindowsDemo");

(Required) App version number

You must specify the version number of the app 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

Limit

Failure

app_version

const char*

Specify a string with less than 64 characters. The parameter is not empty.

The request fails, and the configuration does not take effect.

Example:

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

(Optional) App environment

You must specify the app environment 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

Limit

Failure

env

App environment

Valid values:

  • ALIBABACLOUD_RUM_ENV_PROD

  • ALIBABACLOUD_RUM_ENV_GRAY

  • ALIBABACLOUD_RUM_ENV_PRE

  • ALIBABACLOUD_RUM_ENV_DAILY

  • ALIBABACLOUD_RUM_ENV_LOCAL

The request fails, and the configuration does not take effect.

Example:

alibabacloud_rum_options_set_env(options, ALIBABACLOUD_RUM_ENV_LOCAL);

(Optional) Device ID

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

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

Parameter

Description

Limit

Failure

utdid

Device ID in the const char* format

Specify a string with less than 37 characters. The parameter is not empty.

The request fails, and the configuration does not take effect.

Example:

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

(Optional) Log level

The SDK generates logs at runtime. If you encounter problems when using the SDK, you can adjust the log level before you call the alibabacloud_rum_init function to generate more information for troubleshooting.

void alibabacloud_rum_options_set_debug_level(alibabacloud_rum_options_t *options, alibabacloud_rum_level_t level);

Parameter

Description

Limit

Failure

level

Log level

Valid 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 specifies the highest log level and writes logs to the cache file.

The request fails, and the configuration does not take effect.

Example:

alibabacloud_rum_options_set_debug_level(options, ALIBABACLOUD_RUM_LEVEL_DEBUG);

(Optional) Cache directory

The SDK generates cache files at runtime. By default, the SDK creates a folder named .alibabacloud-rum in the directory where the executable file is located. You can also specify a custom cache directory to store the files 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

Limit

Failure

path

const char*

The length of the directory may be limited by the system. The parameter is not empty.

The request fails, and the configuration does not take effect.

Example:

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

(Optional) Network request collection filter

The SDK supports collecting network request data from libcurl and Chromium Embedded Framework (CEF). You can configure a network request collection filter to specify the URLs from which data is collected 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

Limit

Failure

network_options

Structure of the network request filter

The parameter is not empty. Example:

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 request fails, and the configuration does not take effect.

The following example shows how to use the specified structure to configure the RUM service.

// Indicates whether the specified URL allows collection. 
// If 0 is returned, the URL does not allow data collection. Otherwise, the URL allows data collection. 
int ALIBABACLOUD_RUM_CALLBACK example_should_record_request(const char *url)
{
    LOG("example", "example_should_record_request, url: %s", url);
    return 1;
}

// Indicates whether the specified URL allows end-to-end tracing. 
// If 0 is returned, the URL does not allow end-to-end tracing. Otherwise, the URL allows end-to-end tracing. 
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: By default, the SDK configures network options, collects all URL request data, and does not allow end-to-end tracing for URLs. 
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

By default, the SDK enables the libcurl network data collection module. You can also disable it 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

Limit

Failure

enabled

Integer

Valid values:

  • 0: disables the module.

  • 1: enables the module.

The request fails, and the configuration does not take effect.

Example:

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

Before you enable the libcurl network data collection module, you must configure libcurl. Only libcurl dynamic library data can be collected.

(Optional) Enable or disable the crash data collection module

By default, the SDK enables the crash data collection module. You can also disable it 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

Limit

Failure

enabled

Integer

Valid values:

  • 0: disables the module.

  • 1: enables the module.

The request fails, and the configuration 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 data collection module

By default, the SDK enables the CEF data collection module. You can also disable it 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

Limit

Failure

enabled

Integer

Valid values:

  • 0: disables the module.

  • 1: enables the module.

The request fails, and the configuration does not take effect.

Example:

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

Before you enable the CEF data collection module, you must configure the CEF library. Only CEF dynamic library data can be collected.

(Required) SDK initialization

You can use the alibabacloud_rum_init function to initialize the SDK.

int alibabacloud_rum_init(alibabacloud_rum_options_t *options)

Parameter

Description

Limit

Failure

options

SDK options

The parameter is not empty. You must configure all the required options.

The request fails, and the configuration does not take effect.

(Required) Disable the SDK

You can use the alibabacloud_rum_close function to disable the SDK.

int alibabacloud_rum_close()

Example:

alibabacloud_rum_close()

Custom information

Custom usernames

The SDK allows you to configure user information and further analyze monitoring data related to users. You can configure custom usernames before you call the alibabacloud_rum_init function.

void alibabacloud_rum_set_username(const char *username)

Parameter

Description

Limit

Failure

username

const char*

Specify a string with no more than 256 characters. The parameter is not empty.

The request fails, and the configuration does not take effect.

Example:

alibabacloud_rum_set_username("my nick name is xxxx");

Custom user IDs

The SDK allows you to configure user information and further analyze monitoring data related to users. You can configure custom user IDs before you call the alibabacloud_rum_init function.

void alibabacloud_rum_set_userid(const char *userid)

Parameter

Description

Limit

Failure

userid

const char*

Specify a string with no more than 256 characters. The parameter is not empty.

The request fails, and the configuration does not take effect.

Example:

alibabacloud_rum_set_userid("1234567890");

Custom additional user information

The SDK allows you to configure user information and further analyze monitoring data related to users.

void alibabacloud_rum_set_user_tags(const char *user_tags)

Parameter

Description

Limit

Failure

user_tags

const char*

Specify a string with no more than 512 characters. The parameter is not empty.

The request fails, and the configuration does not take effect.

Custom global attributes

The SDK allows you to configure custom global attributes. After global attributes are customized, new data automatically carries the business attribute information, which is used to analyze requirements associated with the business attributes. After alibabacloud_rum_set_properties function call, the last value is overwritten.

#define alibabacloud_rum_set_properties(...)

Parameter

Description

Limit

Failure

(...)

Key-value pair

You can specify no more than 50 key-value pairs. Each key can contain up to 52 characters. Each string that combines a key and a value can contain up to 2,000 characters.

The request fails, and the configuration does not take effect.

Example:

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

Custom exceptions

You can pass in exception-specific parameters to collect custom exception data. RUM SDKs for C and C++ provide a set of functions for reporting 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

Description

alibabacloud_rum_custom_exception_new

Creates a alibabacloud_rum_custom_exception_t instance.

alibabacloud_rum_custom_exception_set_file

Specifies the source file associated with the exception.

alibabacloud_rum_custom_exception_set_source

Sets the exception source and contains reserved fields.

alibabacloud_rum_custom_exception_set_caused_by

Sets the causes of the exception.

alibabacloud_rum_custom_exception_set_stack

Sets the exception stack.

alibabacloud_rum_custom_exception_free

Releases a alibabacloud_rum_custom_exception_t instance, which is generally not called.

alibabacloud_rum_custom_exception_report

Reports a 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);

Custom events

You can pass in event-specific parameters to collect custom event data. RUM SDKs for C and C++ provide a set of functions for reporting 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

Description

alibabacloud_rum_custom_event_new

Creates a alibabacloud_rum_custom_event_t instance.

alibabacloud_rum_custom_event_set_value

Sets the event attribute.

alibabacloud_rum_custom_event_set_group

Sets the event group.

alibabacloud_rum_custom_event_set_snapshots

Sets event snapshots.

alibabacloud_rum_custom_event_add_extra

Sets extended event parameters.

alibabacloud_rum_custom_event_free

Releases a alibabacloud_rum_custom_event_t instance, which is generally not called.

alibabacloud_rum_custom_event_report

Reports custom events.

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);

Custom logs

You can pass in log-specific parameters to collect custom log data. RUM SDKs for C and C++ provide a set of functions for reporting 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

Description

alibabacloud_rum_custom_log_t

Creates a alibabacloud_rum_custom_log_t instance.

alibabacloud_rum_custom_log_set_log

Sets the log content.

alibabacloud_rum_custom_log_set_value

Sets the log attribute.

alibabacloud_rum_custom_log_set_group

Sets the log group.

alibabacloud_rum_custom_log_set_snapshots

Sets log snapshots.

alibabacloud_rum_custom_log_add_extra

Sets extended log parameters.

alibabacloud_rum_custom_log_free

Releases a alibabacloud_rum_custom_log_t instance, which is generally not called.

alibabacloud_rum_custom_log_report

Reports custom logs.

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, "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);