tencent cloud

All product documents
Tencent Cloud Observability Platform
Setting Checkpoints
Last updated: 2025-03-10 22:14:20
Setting Checkpoints
Last updated: 2025-03-10 22:14:20

Overview

You can use custom checkpoints to check whether the response results of requests meet business expectations. The check results will be summarized into checkpoint metrics for you to view details in the performance testing report.
Additionally, you can enable recording of associated logs for checkpoints and requests to view checkpoint information related to the requests on the request sampling side.

Usage

1. Defining Checkpoints

The PTS JavaScript API provides the check method to create checkpoints.
The input parameters of the check method are as follows:
name: name of the checkpoint.
callback: function used for checking, which should return a value of the Boolean type.
response (optional): response to the request being checked, which is used to enable checkpoint log recording.
The return value of the check method is of the Boolean type, indicating whether this check is successful.
A basic example is as follows:
import http from 'pts/http';
import { check } from 'pts';
export default function () {
const resp = http.get('http://mockhttpbin.pts.svc.cluster.local/get');
check('statusCode is 200', () => resp.statusCode === 200); // Set a checkpoint to collect statistics on checkpoint metrics.
check('statusCode is 200', () => resp.statusCode === 200, resp); // Set a checkpoint to collect statistics on checkpoint metrics and record checkpoint logs.
};
A common check logic example is as follows:
import { check } from 'pts';

export default function () {
check("is empty", () => "" === "") // true
//@ts-ignore
check("is not empty", () => "str" !== "") // true
check("equals", () => 1.00 == 1) // true
check("not equal", () => 1.00 === 1) // true
check("less than", () => 1 < 2) // true
check("less or equal", () => 1 <= 1) // true
check("greater than", () => 2 > 1) // true
check("greater or equal", () => 2 >= 2) // true
check("has key", () => ({key:"value"}).hasOwnProperty("key")) // true
check("string has value", () => "str".includes("s")) // true
check("array has value", () => ["a", "b", "c"].includes("a")) // true
};
Note:
For more detailed API documentation, see pts.check.

1. Viewing Check Results

Metric Details

Log in to the TCOP console and select PTS > Test Scenarios in the left sidebar. On the performance testing report page, click Checkpoint Details and view the multidimensional metrics summarized from all check results.




Associated Requests

When calling the check method, if you pass in optional response parameters, the check results will be recorded in the request sampling logs in addition to being reflected in the above checkpoint metrics. You can view them on the request sampling page.



Click to select the sampling item you want to view.



Click a sampling request to enter the details page, where you can view the checkpoint content associated with the sampling request.




Log Printing of Checkpoints and Corresponding Requests

Checkpoints are logically separated from requests. A request can correspond to multiple checkpoints, and a checkpoint can check non-request content. At the same time, a request is responded normally (status code: 200), but the checkpoint may still fail, depending on the check conditions configured by users.
import http from 'pts/http';
import { check, sleep } from 'pts';
export default function () {
const resp = http.get('http://mockhttpbin.pts.svc.cluster.local/get', {
headers: {
Connection: 'keep-alive',
'User-Agent': 'pts-engine',
},
query: {
name1: 'value1',
name2: 'value2',
},
});
// A request can correspond to multiple checkpoints.
check('status is 200', () => resp.statusCode === 200, resp);
check('body.args.name1 equals value1', () => resp.json().args.name1 === 'value1', resp);
// The status code 200 is returned for a request, but the checkpoint may still fail (depending on the check conditions configured by users).
check('body.args.name1 equals value2', () => resp.json().args.name1 === 'value2', resp);
// A checkpoint can check non-request content.
let v = 1;
check("v==1", () => v==1);
check("v==2", () => v==2);
}
However, in actual use, checkpoints and requests are often used together to check whether the request response meets expectations. Therefore, it is crucial to obtain the association between checkpoints and requests.
In the Associated Requests section, by setting the response parameters in the check method, you can record the checkpoint results in the request sampling logs, which meets the association requirements for both in some cases. However, in certain situations, there may be more customized requirements for details. In this case, you can print the required content in logs within the check conditions of a checkpoint to view more details.
import http from 'pts/http';
import { check } from 'pts';
export default function () {
const resp = http.get('http://mockhttpbin.pts.svc.cluster.local/get', {
query: {
name1: 'value1',
},
});
// Print user logs within the check conditions of a checkpoint.
check('body.args.name1 equals value2', () => {
if (resp.json().args.name1 === 'value2') {
return true
};
console.log(resp.body);
console.log(`check not pass, name1 need value2 but ${resp.json().args.name1}`);
return false;
});
}

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon