tencent cloud

Tencent Cloud Observability Platform

Release Notes and Announcements
Release Notes
Product Introduction
Overview
Strengths
Basic Features
Basic Concepts
Use Cases
Use Limits
Purchase Guide
Tencent Cloud Product Monitoring
Application Performance Management
Mobile App Performance Monitoring
Real User Monitoring
Cloud Automated Testing
Prometheus Monitoring
Grafana
EventBridge
PTS
Quick Start
Monitoring Overview
Instance Group
Tencent Cloud Product Monitoring
Application Performance Management
Real User Monitoring
Cloud Automated Testing
Performance Testing Service
Prometheus Getting Started
Grafana
Dashboard Creation
EventBridge
Alarm Service
Cloud Product Monitoring
Tencent Cloud Service Metrics
Operation Guide
CVM Agents
Cloud Product Monitoring Integration with Grafana
Troubleshooting
Practical Tutorial
Application Performance Management
Product Introduction
Access Guide
Operation Guide
Practical Tutorial
Parameter Information
FAQs
Mobile App Performance Monitoring
Overview
Operation Guide
Access Guide
Practical Tutorial
Tencent Cloud Real User Monitoring
Product Introduction
Operation Guide
Connection Guide
FAQs
Cloud Automated Testing
Product Introduction
Operation Guide
FAQs
Performance Testing Service
Overview
Operation Guide
Practice Tutorial
JavaScript API List
FAQs
Prometheus Monitoring
Product Introduction
Access Guide
Operation Guide
Practical Tutorial
Terraform
FAQs
Grafana
Product Introduction
Operation Guide
Guide on Grafana Common Features
FAQs
Dashboard
Overview
Operation Guide
Alarm Management
Console Operation Guide
Troubleshooting
FAQs
EventBridge
Product Introduction
Operation Guide
Practical Tutorial
FAQs
Report Management
FAQs
General
Alarm Service
Concepts
Monitoring Charts
CVM Agents
Dynamic Alarm Threshold
CM Connection to Grafana
Documentation Guide
Related Agreements
Application Performance Management Service Level Agreement
APM Privacy Policy
APM Data Processing And Security Agreement
RUM Service Level Agreement
Mobile Performance Monitoring Service Level Agreement
Cloud Automated Testing Service Level Agreement
Prometheus Service Level Agreement
TCMG Service Level Agreements
PTS Service Level Agreement
PTS Use Limits
Cloud Monitor Service Level Agreement
API Documentation
History
Introduction
API Category
Making API Requests
Monitoring Data Query APIs
Alarm APIs
Legacy Alert APIs
Notification Template APIs
TMP APIs
Grafana Service APIs
Event Center APIs
TencentCloud Managed Service for Prometheus APIs
Monitoring APIs
Data Types
Error Codes
Glossary

Protobuf-based Performance Testing

PDF
フォーカスモード
フォントサイズ
最終更新日: 2025-03-10 22:14:19
This document introduces how to use the serialization protocol Protobuf.

Protocol File Upload

Before using the Protobuf protocol, you need to upload .proto files. The performance testing engine relies on protocol files to complete the serialization of requests. You can upload files or directories. File names should be unique, and existing files with the same name will be overwritten by newly uploaded files. If you upload a ZIP file, PTS will decompress the file and display the structure of the decompressed file. If the directory or ZIP package contains files other than .proto files, PTS will ignore these files.



Note:
For multi-protocol files, see Using Protocol Files.
With the .proto files you upload, you can serialize/deserialize objects in the script. If demo.proto depends on other .proto files, they also need to be uploaded together (the standard .proto files provided by Google, namely, google/protobuf/*.proto, do not need to be uploaded separately because PTS will load them automatically). You only need to load the main .proto file, and other .proto files that the main .proto file depends on will be loaded recursively.

Example





Protocol File

duty.proto

syntax = "proto3";

message Duty {
string time = 1;
string work = 2;
}

student.proto

syntax = "proto3";
import "duty.proto";

package student;

message Student {
string name = 1;
Gender gender = 2;

message GradeInfo {
enum Grade {
DEFAULT = 0;
FIRST = 1;
SECOND = 2;
THIRD = 3;
}
Grade grade = 1;
}
GradeInfo gradeInfo = 3;
map<string, int32> scores = 4;
repeated Duty duties = 5;
}

enum Gender {
DEFAULT = 0;
FEMALE = 1;
MALE = 2;
}

message SearchRequest {
string id = 1;
}

message SearchResponse {
message Result {
Student student = 1;

}
}

service SearchService {
rpc SearchScores (SearchRequest) returns (SearchResponse);
}

Script

import protobuf from 'pts/protobuf';


// Load the student.proto file in the root directory of the protocol files. The duty.proto file will be loaded at the same time.
protobuf.load([], 'student.proto');


// Load the student.proto file in the dirName directory of the protocol files.
// protobuf.load(['dirName'], 'student.proto');


export default function () {
let bodyBuffer = protobuf.marshal('student.Student', {
'name': 'Alice',
'gender': 1, // Alternatively, set it to FEMALE. You can directly set the specific value for enum.
'gradeInfo': {
'grade': 'THIRD'
},
'scores': {
'Chinese': 116,
'Math': 120,
'English': 106
},
'duties': [
{
'time': 'time1',
'work': 'work1'
},
{
'time': 'time2',
'work': 'work2'
}
]
});

const value = protobuf.unmarshal('student.Student', bodyBuffer);
// {"name":"Alice","gender":"FEMALE","gradeInfo":{"grade":"THIRD"},"scores":{"Math":120,"Chinese":116,"English":106},"duties":[{"time":"time","work":"work"}]}
console.log(JSON.stringify(value));
}


ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック