aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/interop/metrics_client.cc
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2016-08-26 13:01:15 -0700
committerGravatar Mark D. Roth <roth@google.com>2016-08-26 13:01:15 -0700
commit366c6ceb8c53a4f8c4a2f9aa2c6fee8f2a070479 (patch)
tree32ad24fe9b02e6354037a9f2ca78b219537f2afe /test/cpp/interop/metrics_client.cc
parentb9151e3c0b0a5d01d6077c50e3ed483cb1f49b10 (diff)
parent4275e60eb686ceb202c042fe578c9cf992e590d0 (diff)
Merge remote-tracking branch 'upstream/master' into run_interop_tests_go
Diffstat (limited to 'test/cpp/interop/metrics_client.cc')
-rw-r--r--test/cpp/interop/metrics_client.cc27
1 files changed, 13 insertions, 14 deletions
diff --git a/test/cpp/interop/metrics_client.cc b/test/cpp/interop/metrics_client.cc
index 7a0cb994df..179de30805 100644
--- a/test/cpp/interop/metrics_client.cc
+++ b/test/cpp/interop/metrics_client.cc
@@ -56,6 +56,9 @@ using grpc::testing::GaugeResponse;
using grpc::testing::MetricsService;
using grpc::testing::MetricsServiceImpl;
+// Do not log anything
+void BlackholeLogger(gpr_log_func_args* args) {}
+
// Prints the values of all Gauges (unless total_only is set to 'true' in which
// case this only prints the sum of all gauge values).
bool PrintMetrics(std::unique_ptr<MetricsService::Stub> stub, bool total_only,
@@ -76,21 +79,21 @@ bool PrintMetrics(std::unique_ptr<MetricsService::Stub> stub, bool total_only,
while (reader->Read(&gauge_response)) {
if (gauge_response.value_case() == GaugeResponse::kLongValue) {
if (!total_only) {
- gpr_log(GPR_INFO, "%s: %lld", gauge_response.name().c_str(),
- gauge_response.long_value());
+ std::cout << gauge_response.name() << ": "
+ << gauge_response.long_value() << std::endl;
}
overall_qps += gauge_response.long_value();
} else {
- gpr_log(GPR_INFO, "Gauge %s is not a long value",
- gauge_response.name().c_str());
+ std::cout << "Gauge '" << gauge_response.name() << "' is not long valued"
+ << std::endl;
}
}
- gpr_log(GPR_INFO, "%ld", overall_qps);
+ std::cout << overall_qps << std::endl;
const grpc::Status status = reader->Finish();
if (!status.ok()) {
- gpr_log(GPR_ERROR, "Error in getting metrics from the client");
+ std::cout << "Error in getting metrics from the client" << std::endl;
}
return status.ok();
@@ -99,14 +102,10 @@ bool PrintMetrics(std::unique_ptr<MetricsService::Stub> stub, bool total_only,
int main(int argc, char** argv) {
grpc::testing::InitTest(&argc, &argv, true);
- // Make sure server_addresses flag is not empty
- if (FLAGS_metrics_server_address.empty()) {
- gpr_log(
- GPR_ERROR,
- "Cannot connect to the Metrics server. Please pass the address of the"
- "metrics server to connect to via the 'metrics_server_address' flag");
- return 1;
- }
+ // The output of metrics client is in some cases programatically parsed (for
+ // example by the stress test framework). So, we do not want any of the log
+ // from the grpc library appearing on stdout.
+ gpr_set_log_function(BlackholeLogger);
std::shared_ptr<grpc::Channel> channel(grpc::CreateChannel(
FLAGS_metrics_server_address, grpc::InsecureChannelCredentials()));