Example: lr_user_data_point_instance_ex

The following segment checks the CPU every second and records the result.

In the following example, a user data point instance records the amount overdrawn on a bank account during a specific transaction instance whose id is instance_id. The data point's log flag is Extended and will be logged if VuGen's Log runtime setting is set at Extended level.

int LIMIT=1000;
long instance_id;
int amount_overdrawn;
amount_overdrawn = get_amount_overdrawn();
while (amount_overdrawn < LIMIT) {
     /* Notify that a transaction is starting */
     instance_id = lr_start_transaction_instance("withdraw", 0);
     status = bank_withdraw(500); /* Call to server API */
     /* End transaction with operation result - pass or fail */
    if (status == 0)
          lr_end_transaction_instance(instance_id, LR_PASS);
          lr_end_transaction_instance(instance_id, LR_FAIL);
     amount_overdrawn = get_amount_overdrawn();
     /* Record the amount overdrawn as a data point and associate it with 
     * the specific transaction instance by using the instance's id */
     lr_user_data_point_instance_ex("Amount Overdrawn",
          (double)amount_overdrawn, instance_id,