mirror of
https://github.com/valitydev/osquery-1.git
synced 2024-11-07 01:55:20 +00:00
Fix error handling in AWS logger plugins (#3426)
This commit is contained in:
parent
43046f48da
commit
b86869208d
@ -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()) {
|
||||
|
@ -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()
|
||||
|
@ -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(
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user