tencent cloud

Tencent Cloud Observability Platform

pts.check

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 2025-03-11 19:41:13
During the script execution, perform further checks on the results returned by the request; if a failure is returned, it indicates that the current check has not passed.
check(name: string, callback: () => boolean, response?: Response): boolean

Parameters

Parameter
Type
Description
name
string
The name of the checkpoint.
callback
function
The function used for check, which should return a boolean type.
response (optional)
Response
Pass in the response of the request being checked to enable recording of the checkpoint logs.

Return

Type
Description
boolean
The result of the check. true indicates the check passed, and false indicates the check failed.

Samples

Check whether the response status code of the HTTP request is 200:
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.
};


Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan