All Products
Search
Document Center

Cloud Monitor:SDK configuration reference

Last Updated:Jun 17, 2026

Cloud Monitor 2.0 provides a C/C++ SDK for Real User Monitoring (RUM) on PC applications. Configure the SDK by setting options on an alibabacloud_rum_options_t struct before calling alibabacloud_rum_init().

Quick start

Minimal initialization with all required options:

int main(void) {
    // Create the options struct
    alibabacloud_rum_options_t *options = alibabacloud_rum_options_new();

    // Required: set the config address, app ID, and app version
    alibabacloud_rum_options_set_config_address(options, "<your-config-address>");
    alibabacloud_rum_options_set_app_id(options, "<your-app-id>");
    alibabacloud_rum_options_set_app_version(options, "1.0.0");

    // Initialize the SDK
    int result = alibabacloud_rum_init(options);

    /* ... your application logic ... */

    // Shut down the SDK before exiting
    alibabacloud_rum_close();
    return 0;
}

Replace the following placeholders with actual values:

Placeholder Description Where to find
<your-config-address> Configuration address for your application Real User Monitoring platform
<your-app-id> Unique application ID Real User Monitoring platform

Startup configuration

Call all startup configuration functions before alibabacloud_rum_init. The SDK stops if any required option is missing or invalid.

Set the config address (required)

Specify the configuration endpoint for your application.

void alibabacloud_rum_options_set_config_address(alibabacloud_rum_options_t *options, const char *config_address);
Parameter Type Constraints On failure
options alibabacloud_rum_options_t * Not empty. Create with alibabacloud_rum_options_new(). Call fails; SDK stops.
config_address const char * Not empty. Generated by the Real User Monitoring platform. Call fails; SDK stops.

Example:

alibabacloud_rum_options_set_config_address(options, RUM_CONFIG_ADDRESS);

Set the application ID (required)

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

void alibabacloud_rum_options_set_app_id(alibabacloud_rum_options_t *options, const char *app_id)
Parameter Type Constraints On failure
app_id const char * Not empty. Unique application ID from the Real User Monitoring platform. Call fails; SDK stops.

Example:

alibabacloud_rum_options_set_app_id(options, RUM_CONFIG_APPID);

Set the application version (required)

Specify a version string for your application.

void alibabacloud_rum_options_set_app_version(alibabacloud_rum_options_t *options, const char *app_version)
Parameter Type Constraints On failure
app_version const char * Not empty. 1-63 characters. Call fails; version setting does not take effect.

Example:

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

Set the application environment (optional)

Tag data with the deployment environment for filtering in the monitoring dashboard.

void alibabacloud_rum_options_set_env(alibabacloud_rum_options_t *options, alibabacloud_rum_env_t env)
Parameter Type Constraints On failure
env alibabacloud_rum_env_t One of the enumeration values listed below. Call fails; environment setting does not take effect.

Supported values:

Value Environment
ALIBABACLOUD_RUM_ENV_PROD Production
ALIBABACLOUD_RUM_ENV_GRAY Canary (gray)
ALIBABACLOUD_RUM_ENV_PRE Pre-release
ALIBABACLOUD_RUM_ENV_DAILY Daily build
ALIBABACLOUD_RUM_ENV_LOCAL Local development

Example:

alibabacloud_rum_options_set_env(options, ALIBABACLOUD_RUM_ENV_LOCAL);

Set a custom device ID (optional)

Override the auto-generated device ID with a custom value. By default, the SDK generates a device ID and caches it to a local file.

void alibabacloud_rum_options_set_utdid(alibabacloud_rum_options_t *options, const char *utdid)
Parameter Type Constraints Default On failure
utdid const char * Not empty. 1-36 characters. Auto-generated and cached locally. Call fails; device ID setting does not take effect.

Example:

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

Set the log level (optional)

Adjust SDK log verbosity for troubleshooting. Higher levels produce more detailed output.

void alibabacloud_rum_options_set_debug_level(alibabacloud_rum_options_t *options, alibabacloud_rum_level_t level);
Parameter Type Constraints On failure
level alibabacloud_rum_level_t One of the enumeration values listed below. Call fails; log level setting does not take effect.

Supported values (from least to most verbose):

Value Level
ALIBABACLOUD_RUM_LEVEL_FATAL Fatal
ALIBABACLOUD_RUM_LEVEL_ERROR Error
ALIBABACLOUD_RUM_LEVEL_WARNING Warning
ALIBABACLOUD_RUM_LEVEL_INFO Info
ALIBABACLOUD_RUM_LEVEL_DEBUG Debug
ALIBABACLOUD_RUM_LEVEL_TRACE Trace
ALIBABACLOUD_RUM_LEVEL_ALL All (writes logs to the cache file)

Example:

alibabacloud_rum_options_set_debug_level(options, ALIBABACLOUD_RUM_LEVEL_DEBUG);

Set the cache directory (optional)

Specify a custom directory for SDK cache files. By default, the SDK creates a .alibabacloud-rum folder in the same directory as the executable.

void alibabacloud_rum_options_set_cache_path(alibabacloud_rum_options_t *options, const char *path)
Parameter Type Constraints Default On failure
path const char * Not empty. Maximum length is OS-dependent. .alibabacloud-rum in the executable directory. Call fails; cache directory setting does not take effect.

Example:

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

Enable or disable crash tracking (optional)

Toggle crash data collection. Enabled by default. Call this function before alibabacloud_rum_init.

void alibabacloud_rum_options_set_auto_crash_tracking(alibabacloud_rum_options_t *options, int enabled)
Parameter Type Values Default
enabled int 1 = enable, 0 = disable 1 (enabled)

Example:

alibabacloud_rum_options_set_auto_crash_tracking(options, 1);

Network request collection

The SDK collects network request data from libcurl and Chromium Embedded Framework (CEF). Call all functions in this section before alibabacloud_rum_init.

Set a network request filter (optional)

Control which URLs the SDK collects network data from and which URLs participate in end-to-end tracing.

void alibabacloud_rum_options_set_network_options(alibabacloud_rum_options_t *options, alibabacloud_rum_network_options_t *network_options)

The alibabacloud_rum_network_options_t struct provides two callback functions:

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;
Callback Return 0 Return non-zero Default behavior
should_record_request Skip collection for this URL. Collect request data for this URL. Collect all URLs.
should_tracing Allow end-to-end tracing for this URL. Block tracing for this URL. Block tracing for all URLs.

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

Enable or disable libcurl tracking (optional)

Toggle network data collection from the libcurl dynamic library. Enabled by default.

void alibabacloud_rum_options_set_auto_curl_tracking(alibabacloud_rum_options_t *options, int enabled)
Parameter Type Values Default
enabled int 1 = enable, 0 = disable 1 (enabled)
Important

Integrate the libcurl library before you enable this module. Only data from the libcurl dynamic library can be collected.

Example:

alibabacloud_rum_options_set_auto_curl_tracking(options, 1);

Enable or disable CEF tracking (optional)

Toggle data collection from the Chromium Embedded Framework (CEF). Disabled by default.

void alibabacloud_rum_options_set_auto_cef_tracking(alibabacloud_rum_options_t *options, int enabled)
Parameter Type Values Default
enabled int 1 = enable, 0 = disable 0 (disabled)
Important

Integrate the CEF library before you enable this module. Only data from the CEF dynamic library can be collected.

Example:

alibabacloud_rum_options_set_auto_cef_tracking(options, 1);

SDK lifecycle

Initialize the SDK (required)

Start the SDK after all startup configuration is complete.

int alibabacloud_rum_init(alibabacloud_rum_options_t *options)
Parameter Type Constraints On failure
options alibabacloud_rum_options_t * Not empty. All required parameters must be set. Call fails; SDK stops.

Shut down the SDK (required)

Release SDK resources and flush any pending data before your application exits.

int alibabacloud_rum_close()

Example:

alibabacloud_rum_close();

User identification

Associate monitoring data with specific users by setting user identity fields. Call these functions after alibabacloud_rum_init.

Set the username

void alibabacloud_rum_set_username(const char *username)
Parameter Type Constraints On failure
username const char * Not empty. Maximum 256 characters. Call fails; setting does not take effect.

Example:

alibabacloud_rum_set_username("my nick name is xxxx");

Set the user ID

void alibabacloud_rum_set_userid(const char *userid)
Parameter Type Constraints On failure
userid const char * Not empty. Maximum 256 characters. Call fails; setting does not take effect.

Example:

alibabacloud_rum_set_userid("1234567890");

Set user tags

Attach custom tags to the current user for filtering and grouping in analytics.

void alibabacloud_rum_set_user_tags(const char *user_tags)
Parameter Type Constraints On failure
user_tags const char * Not empty. Maximum 512 characters. Call fails; setting does not take effect.

Global properties

Set custom key-value pairs that attach automatically to all subsequent data. Each call to alibabacloud_rum_set_properties overwrites all previously set properties.

#define alibabacloud_rum_set_properties(...)
Parameter Type Constraints On failure
(...) Key-value pairs Maximum 50 pairs. Key length: maximum 52 characters. Total string length of all pairs: maximum 2,000 characters. Call fails; setting does not take effect.

Example:

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

Custom data reporting

Report application-specific exceptions, events, and logs to the RUM platform.

Report a custom exception

Create and report a custom exception with contextual details.

Functions:

Function Description
alibabacloud_rum_custom_exception_new(name, message) Create an alibabacloud_rum_custom_exception_t instance.
alibabacloud_rum_custom_exception_set_file(event, file) Set the source file associated with the exception.
alibabacloud_rum_custom_exception_set_source(event, source) Set the exception source. Reserved for future use.
alibabacloud_rum_custom_exception_set_caused_by(event, caused_by) Set the root cause of the exception.
alibabacloud_rum_custom_exception_set_stack(event, stack) Set the exception stack trace.
alibabacloud_rum_custom_exception_free(event) Release the instance. Not typically required.
alibabacloud_rum_custom_exception_report(event) Submit the exception to the RUM platform.

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

Create and report a custom event with associated metrics and metadata.

Functions:

Function Description
alibabacloud_rum_custom_event_new(type, name) Create an alibabacloud_rum_custom_event_t instance.
alibabacloud_rum_custom_event_set_value(event, value) Set a numeric value for the event.
alibabacloud_rum_custom_event_set_group(event, group) Set the event group.
alibabacloud_rum_custom_event_set_snapshots(event, snapshots) Set the event snapshot.
alibabacloud_rum_custom_event_add_extra(event, k, v) Add an extra key-value pair.
alibabacloud_rum_custom_event_free(event) Release the instance. Not typically required.
alibabacloud_rum_custom_event_report(event) Submit the event to the RUM platform.

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

Create and report a custom log entry with severity level and content.

Functions:

Function Description
alibabacloud_rum_custom_log_new(type, name) Create an alibabacloud_rum_custom_log_t instance.
alibabacloud_rum_custom_log_set_log(log, level, content) Set the log level and content.
alibabacloud_rum_custom_log_set_value(log, value) Set a numeric value for the log.
alibabacloud_rum_custom_log_set_group(log, group) Set the log group.
alibabacloud_rum_custom_log_set_snapshots(log, snapshots) Set the log snapshot.
alibabacloud_rum_custom_log_add_extra(log, k, v) Add an extra key-value pair.
alibabacloud_rum_custom_log_free(log) Release the instance. Not typically required.
alibabacloud_rum_custom_log_report(log) Submit the log to the RUM platform.

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