Cloud Monitor 2.0 monitors PC applications using a cross-platform C/C++ API dynamic library. This topic describes how to integrate Windows and macOS applications with Real User Monitoring (RUM) using the C/C++ software development kit (SDK).
Supported versions and architecture
RUM SDKs for C and C++ support the following Windows and macOS versions and architecture.
Operating system | Operating system version | Architecture |
Windows | 7+ | x86 and x86-64 |
macOS | 10.13+ | x86-64 and ARM64 |
Step 1: Create an application
Log on to the Cloud Monitor 2.0 console, and select a workspace. In the left navigation pane, click Integration Center.
Click the Windows or macOS card, select a region, enter an application name and description, and then click Create Application.
NoteThe application name must be unique.
After the application is created, a ConfigAddress (reporting address) and an AppID are automatically generated for the application.
Step 2: Integrate the SDK
1. Download the SDK
Operating system | Architecture | Dynamic library |
Windows |
| https://rum-sdk.oss-cn-hangzhou.aliyuncs.com/native/AlibabaCloud_RUM_Windows_0.2.1.zip |
macOS |
| https://rum-sdk.oss-cn-hangzhou.aliyuncs.com/native/AlibabaCloud_RUM_macOS_0.2.1.zip |
SDK description:
Features:
Collection of page view and unique visitor statistics
Crash data capture
Collection of network service data from libcurl and Chromium Embedded Framework (CEF)
Custom event reporting
Dynamic libraries:
macOS:
dylibWindows:
dll
Currently, data collection can be configured only for dynamic libraries.
2. Initialize the SDK
Add the header file dependency.
Include the header file for both Windows and macOS.
#include "alibabacloud_rum.h"Initialize the SDK.
The SDK supports various configurations.
alibabacloud_rum_options_t *options = alibabacloud_rum_options_new(); // Required. Specify the address. alibabacloud_rum_options_set_config_address(options, "<your config address>"); // Required. Specify the app ID. alibabacloud_rum_options_set_app_id(options, "<your appId>"); // Required. Specify the app version. alibabacloud_rum_options_set_app_version(options, "0.1.0"); // Optional. Specify whether you are using a development environment or a production environment. The default value is ALIBABACLOUD_RUM_ENV_PROD. alibabacloud_rum_options_set_env(options, ALIBABACLOUD_RUM_ENV_PROD); // Optional. Specify whether to enable crash data capture. By default, this feature is enabled. alibabacloud_rum_options_set_auto_crash_tracking(options, 1); // Optional. Specify whether to enable curl network data collection. By default, this feature is enabled. alibabacloud_rum_options_set_auto_curl_tracking(options, 1); // Optional. Specify whether to enable CEF network request data collection. By default, this feature is disabled. alibabacloud_rum_options_set_auto_cef_tracking(options, 1); // Optional. Configure collection filters for network request data. The following configurations are supported: // 1. When the should_tracing function returns 0, the end-to-end connection for the current URL is not enabled. The default value is 0, indicating that end-to-end connection is not supported for all URL requests. // 2. When the should_record_request function returns 0, the current URL is not collected. The default value is 1, indicating that all URL requests are collected. 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. Initialize the SDK. alibabacloud_rum_init(options);
Verify the result
If the [AlibabaCloud-RUM] [INFO] [Init] alibabacloud rum init success. log appears after the app runs, the SDK initialization is successful.
Sample log entry:
2024-07-25 17:27:27.647 [AlibabaCloud-RUM] [INFO] [Init] alibabacloud rum init success.Disable the SDK
If you no longer want to use the RUM SDK to monitor your PC app, you can call the following function to disable the SDK.
After you call the function, the SDK configurations will be destroyed, all SDK features will be stopped, and memory resources will be revoked.
alibabacloud_rum_close();A brief block may occur when you call the function because the system needs to revoke the resources, and complete the backend asynchronous operations.