tencent cloud

Tencent Cloud Observability Platform

pts.check

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 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.
};


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백