Fix error handling in AWS logger plugins (#3426)

This commit is contained in:
Zachary Wasserman 2017-07-22 22:41:39 -04:00 committed by Teddy Reed
parent 43046f48da
commit b86869208d
4 changed files with 16 additions and 2 deletions

View File

@ -100,6 +100,12 @@ Status FirehoseLogForwarder::send(std::vector<std::string>& log_data,
Aws::Firehose::Model::PutRecordBatchOutcome outcome =
client_->PutRecordBatch(request);
if (!outcome.IsSuccess()) {
LOG(ERROR) << "Firehose write failed: " << outcome.GetError().GetMessage();
return Status(1, outcome.GetError().GetMessage());
}
Aws::Firehose::Model::PutRecordBatchResult result = outcome.GetResult();
if (result.GetFailedPutCount() != 0) {
for (const auto& record : result.GetRequestResponses()) {

View File

@ -132,6 +132,12 @@ Status KinesisLogForwarder::send(std::vector<std::string>& log_data,
Aws::Kinesis::Model::PutRecordsOutcome outcome =
client_->PutRecords(request);
if (!outcome.IsSuccess()) {
LOG(ERROR) << "Kinesis write failed: " << outcome.GetError().GetMessage();
return Status(1, outcome.GetError().GetMessage());
}
Aws::Kinesis::Model::PutRecordsResult result = outcome.GetResult();
VLOG(1) << "Successfully sent "
<< result.GetRecords().size() - result.GetFailedRecordCount()

View File

@ -54,7 +54,8 @@ TEST_F(FirehoseTests, test_send) {
forwarder.client_ = client;
std::vector<std::string> logs{"{\"foo\":\"bar\"}"};
Aws::Firehose::Model::PutRecordBatchOutcome outcome;
Aws::Firehose::Model::PutRecordBatchOutcome outcome(
Aws::Firehose::Model::PutRecordBatchResult{});
outcome.GetResult().SetFailedPutCount(0);
EXPECT_CALL(*client,
PutRecordBatch(Property(

View File

@ -56,7 +56,8 @@ TEST_F(KinesisTests, test_send) {
forwarder.client_ = client;
std::vector<std::string> logs{"{\"foo\":\"bar\"}"};
Aws::Kinesis::Model::PutRecordsOutcome outcome;
Aws::Kinesis::Model::PutRecordsOutcome outcome(
Aws::Kinesis::Model::PutRecordsResult{});
outcome.GetResult().SetFailedRecordCount(0);
EXPECT_CALL(
*client,