Log the peer address of grpc_cli CallMethod RPCs to stderr

pull/23557/head
Alexander Polcyn 5 years ago
parent b5b8578b3f
commit 4bdbd4caef
  1. 2
      test/cpp/util/cli_call.h
  2. 6
      test/cpp/util/grpc_tool.cc

@ -84,6 +84,8 @@ class CliCall final {
// Finish the RPC.
Status Finish(IncomingMetadataContainer* server_trailing_metadata);
std::string peer() const { return ctx_.peer(); }
private:
std::unique_ptr<grpc::GenericStub> stub_;
grpc_impl::ClientContext ctx_;

@ -541,6 +541,8 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
PrintMetadata(client_metadata, "Sending client initial metadata:");
CliCall call(channel, formatted_method_name, client_metadata);
fprintf(stderr, "New call for method_name:%s has peer address:|%s|\n",
formatted_method_name.c_str(), call.peer().c_str());
if (FLAGS_infile.empty()) {
if (isatty(fileno(stdin))) {
@ -670,6 +672,8 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
std::multimap<grpc::string_ref, grpc::string_ref>
server_initial_metadata, server_trailing_metadata;
CliCall call(channel, formatted_method_name, client_metadata);
fprintf(stderr, "New call for method_name:%s has peer address:|%s|\n",
formatted_method_name.c_str(), call.peer().c_str());
call.Write(serialized_request_proto);
call.WritesDone();
if (!call.Read(&serialized_response_proto,
@ -768,6 +772,8 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
PrintMetadata(client_metadata, "Sending client initial metadata:");
CliCall call(channel, formatted_method_name, client_metadata);
fprintf(stderr, "New call for method_name:%s has peer address:|%s|\n",
formatted_method_name.c_str(), call.peer().c_str());
call.Write(serialized_request_proto);
call.WritesDone();

Loading…
Cancel
Save