Menu
Choose a product
Viewing: v0.48.x
Find another version
Scroll for more
Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.
Open source
RSS
k6/net/grpc
Note
A module with streaming support exists.
The new k6/experimental/grpc module extends k6/net/grpc to support gRPC streaming. We recommend using the new module.
The k6/net/grpc module provides a gRPC client for Remote Procedure Calls (RPC) over HTTP/2.
| Class/Method | Description |
|---|---|
| Client | gRPC client used for making RPC calls to a gRPC Server. |
| Client.load(importPaths, …protoFiles) | Loads and parses the given protocol buffer definitions to be made available for RPC requests. |
| Client.connect(address [,params]) | Connects to a given gRPC service. |
| Client.invoke(url, request [,params]) | Makes an unary RPC for the given service/method and returns a Response. |
| Client.close() | Close the connection to the gRPC service. |
| Params | RPC Request specific options. |
| Response | Returned by RPC requests. |
| Constants | Define constants to distinguish between gRPC Response statuses. |
gRPC metrics
k6 takes specific measurements for gRPC requests. For the complete list, refer to the Metrics reference.
Example
JavaScript
JavaScript
import grpc from 'k6/net/grpc';
import { check, sleep } from 'k6';
const client = new grpc.Client();
client.load(['definitions'], 'hello.proto');
export default () => {
client.connect('grpcbin.test.k6.io:9001', {
// plaintext: false
});
const data = { greeting: 'Bert' };
const response = client.invoke('hello.HelloService/SayHello', data);
check(response, {
'status is OK': (r) => r && r.status === grpc.StatusOK,
});
console.log(JSON.stringify(response.message));
client.close();
sleep(1);
};Was this page helpful?
Related resources from Grafana Labs
Additional helpful documentation, links, and articles:
Video

Performance testing and observability in Grafana Cloud
Optimize user experiences with Grafana Cloud. Learn real-time insights, performance testing with k6, and continuous validation with Synthetic Monitoring.
Events

User-centered observability: load testing, real user monitoring, and synthetics
Learn how to use load testing, synthetic monitoring, and real user monitoring (RUM) to understand end users' experience of your apps. Watch on demand.