Cloud Monitor provides a cross-platform C/C++ SDK for monitoring PC applications. Use this SDK to integrate Windows and macOS applications with Real User Monitoring (RUM).
Prerequisites
The C/C++ SDK supports the following platforms. Ensure that your PC application meets these requirements:
|
Platform |
System Version |
Architecture |
|
Windows |
Win7 + |
x86/x86_64 |
|
macOS |
10.13 + |
x86_64/arm64 |
Step 1: Create an Application
-
Log on to the ARMS console. In the navigation pane on the left, choose Real User Monitoring > Application List. Then, in the top menu bar, select the destination region.
-
On the Application List page, click Add Application.
-
In the Create Application panel, click Windows or macOS.
-
In the Windows or macOS panel, enter the application name and description, then click Create.
After successful creation, the application automatically generates a ConfigAddress (reporting address) and an AppID.
Step 2: Access the SDK
1. Download the SDK
|
Platform |
Architecture |
Artifact |
|
Windows |
|
https://rum-sdk.oss-cn-hangzhou.aliyuncs.com/native/AlibabaCloud_RUM_Windows.zip |
|
macOS |
|
https://rum-sdk.oss-cn-hangzhou.aliyuncs.com/native/AlibabaCloud_RUM_macOS.zip |
SDK description:
-
Supported features: PV/UV statistics, crash capture, network services (libcurl, CEF framework data collection), custom event reporting.
-
Artifact types:
-
macOS:
dylibdynamic library -
Windows:
dlldynamic library
-
-
Currently, only dynamic library data collection is supported.
2. Initialize the SDK
-
Add header file dependencies.
Import the following header file on both Windows and macOS:
#include "alibabacloud_rum.h" -
Initialize the SDK.
For details about all supported configuration options, see SDK Configuration Reference.
alibabacloud_rum_options_t *options = alibabacloud_rum_options_new(); // (Required) Obtain the ConfigAddress when creating the RUM application. alibabacloud_rum_options_set_config_address(options, "<your config address>"); // (Required) Obtain the AppId when creating the application. alibabacloud_rum_options_set_app_id(options, "<your appId>"); // (Required) Set the application name. alibabacloud_rum_options_set_app_name(options, "WindowsDemo"); // (Required) Set the application version number. alibabacloud_rum_options_set_app_version(options, "0.1.0"); // (Optional) Set the environment to distinguish between development and production environments. The default value is ALIBABACLOUD_RUM_ENV_PROD. alibabacloud_rum_options_set_env(options, ALIBABACLOUD_RUM_ENV_PROD); // (Optional) Enable crash capture. This is enabled by default. alibabacloud_rum_options_set_auto_crash_tracking(options, 1); // (Optional) Enable cURL network data collection. This is enabled by default. alibabacloud_rum_options_set_auto_cef_tracking(options, 1); // (Optional) Configure network request data collection filters. The following configurations are supported (detailed configuration instructions are provided later): // 1. If the should_tracing function returns 0, end-to-end tracing for the current URL does not take effect. The default return value is 0, meaning end-to-end tracing is not supported for all URL requests. // 2. If the should_record_request function returns 0, data for the current URL is not collected. The default return value is 1, meaning data collection is supported for all URL requests. 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); // (Required) Complete SDK initialization. alibabacloud_rum_init(options);
Step 3: Shut Down the SDK
Calling the shutdown API destroys the SDK instance, stops all functions, and reclaims memory. Use the following call to shut down the SDK:
alibabacloud_rum_close();
Note: This call may briefly block while the SDK performs cleanup and waits for background asynchronous tasks to complete.
Access Verification
After the application starts, the following log entry confirms successful SDK initialization:
Log example:
2024-07-25 17:27:27.647 [AlibabaCloud-RUM] [DEBUG] [Init] alibabacloud rum init success.
Advanced Features
The SDK supports custom event reporting and feature module switches. For more information, see SDK Configuration Reference.