Start to log errors from benchmark

reviewable/pr8239/r2
Craig Tiller 8 years ago
parent 091e4f0ef8
commit 032f9bfb58
  1. 21
      test/cpp/qps/client.h
  2. 11
      test/cpp/qps/client_async.cc

@ -115,17 +115,25 @@ class ClientRequestCreator<ByteBuffer> {
class HistogramEntry GRPC_FINAL { class HistogramEntry GRPC_FINAL {
public: public:
HistogramEntry() : used_(false) {} HistogramEntry() : value_used_(false), status_used_(false) {}
bool used() const { return used_; } bool value_used() const { return value_used_; }
double value() const { return value_; } double value() const { return value_; }
void set_value(double v) { void set_value(double v) {
used_ = true; value_used_ = true;
value_ = v; value_ = v;
} }
bool status_used() const { return status_used_; }
int status() const { return status_; }
void set_status(int status) {
status_used_ = true;
status_ = status;
}
private: private:
bool used_; bool value_used_;
double value_; double value_;
bool status_used_;
int status_;
}; };
typedef std::unordered_map<int, int64_t> StatusHistogram; typedef std::unordered_map<int, int64_t> StatusHistogram;
@ -309,9 +317,12 @@ class Client {
const bool thread_still_ok = client_->ThreadFunc(&entry, idx_); const bool thread_still_ok = client_->ThreadFunc(&entry, idx_);
// lock, update histogram if needed and see if we're done // lock, update histogram if needed and see if we're done
std::lock_guard<std::mutex> g(mu_); std::lock_guard<std::mutex> g(mu_);
if (entry.used()) { if (entry.value_used()) {
histogram_.Add(entry.value()); histogram_.Add(entry.value());
} }
if (entry.status_used()) {
statuses_[entry.value()]++;
}
if (!thread_still_ok) { if (!thread_still_ok) {
gpr_log(GPR_ERROR, "Finishing client thread due to RPC error"); gpr_log(GPR_ERROR, "Finishing client thread due to RPC error");
} }

@ -83,7 +83,7 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext {
BenchmarkService::Stub*, grpc::ClientContext*, const RequestType&, BenchmarkService::Stub*, grpc::ClientContext*, const RequestType&,
CompletionQueue*)> CompletionQueue*)>
start_req, start_req,
std::function<void(grpc::Status, ResponseType*)> on_done) std::function<void(grpc::Status, ResponseType*, HistogramEntry*)> on_done)
: context_(), : context_(),
stub_(stub), stub_(stub),
cq_(nullptr), cq_(nullptr),
@ -113,7 +113,7 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext {
return true; return true;
case State::RESP_DONE: case State::RESP_DONE:
entry->set_value((UsageTimer::Now() - start_) * 1e9); entry->set_value((UsageTimer::Now() - start_) * 1e9);
callback_(status_, &response_); callback_(status_, &response_, entry);
next_state_ = State::INVALID; next_state_ = State::INVALID;
return false; return false;
default: default:
@ -135,7 +135,7 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext {
ResponseType response_; ResponseType response_;
enum State { INVALID, READY, RESP_DONE }; enum State { INVALID, READY, RESP_DONE };
State next_state_; State next_state_;
std::function<void(grpc::Status, ResponseType*)> callback_; std::function<void(grpc::Status, ResponseType*, HistogramEntry*)> callback_;
std::function<gpr_timespec()> next_issue_; std::function<gpr_timespec()> next_issue_;
std::function<std::unique_ptr<grpc::ClientAsyncResponseReader<ResponseType>>( std::function<std::unique_ptr<grpc::ClientAsyncResponseReader<ResponseType>>(
BenchmarkService::Stub*, grpc::ClientContext*, const RequestType&, BenchmarkService::Stub*, grpc::ClientContext*, const RequestType&,
@ -289,7 +289,10 @@ class AsyncUnaryClient GRPC_FINAL
~AsyncUnaryClient() GRPC_OVERRIDE {} ~AsyncUnaryClient() GRPC_OVERRIDE {}
private: private:
static void CheckDone(grpc::Status s, SimpleResponse* response) {} static void CheckDone(grpc::Status s, SimpleResponse* response,
HistogramEntry* entry) {
entry->set_status(s.error_code());
}
static std::unique_ptr<grpc::ClientAsyncResponseReader<SimpleResponse>> static std::unique_ptr<grpc::ClientAsyncResponseReader<SimpleResponse>>
StartReq(BenchmarkService::Stub* stub, grpc::ClientContext* ctx, StartReq(BenchmarkService::Stub* stub, grpc::ClientContext* ctx,
const SimpleRequest& request, CompletionQueue* cq) { const SimpleRequest& request, CompletionQueue* cq) {

Loading…
Cancel
Save