gRPC stream logging

Hi, currently I’m learning k6, I have a script as below:

import grpc from 'k6/net/grpc';
import { check, sleep } from 'k6';

const client = new grpc.Client();
client.load(['protobuf'], 'relay-server.proto');

export default () => {
  client.connect('url:80/relay', {
  });

  const data = { id: 'testing123'};
  const response = client.invoke('relay.HelloService/StartPairing', data);
  
  check(response, {
    'status is OK': (r) => r && r.status === grpc.StatusOK,
  });

  console.log(JSON.stringify(response.message));

  client.close();
  sleep(1);
};

Running the test, I would get a deadline exceeded, I also want to see what the stream was returning, but checking docs does not give me any results yet, how do I enable log for streaming ?

Hi @trinp

Welcome to the community forum :wave:

Did you try debugging with --http-debug=full? I ran the example in k6/net/grpc | Grafana k6 documentation with k6 run test.js and I get INFO as below:

INFO[0000] Out Header:
Full Method: /hello.HelloService/SayHello
Remote Address: 44.214.199.109:9001
user-agent: grpc-go/1.58.3
  source=http-debug
INFO[0000] Out Payload:
Wire Length: 11
Sent Time: 2024-01-03 12:23:41.979605 +0100 CET m=+0.667500376
greeting: "Bert"

  source=http-debug
INFO[0000] In Header:
Wire Length: 14
content-type: application/grpc
  source=http-debug
INFO[0000] In Payload:
Wire Length: 17
Received Time: 2024-01-03 12:23:42.09266 +0100 CET m=+0.780554960
reply: "hello Bert"

Which includes the response. That might help. Some debugging strategies are discussed in k6-learn/Modules/III-k6-Intermediate/01-How-to-debug-k6-load-testing-scripts.md at main · grafana/k6-learn · GitHub.

I hope this helps :bowing_woman:

Cheers!