diff --git a/package.json b/package.json index bb072ba2..3a9b94ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@alertlogic/paws-collector", - "version": "2.2.5", + "version": "2.2.6", "license": "MIT", "description": "Alert Logic AWS based API Poll Log Collector Library", "repository": { @@ -34,12 +34,12 @@ "mocha": "^10.4.0", "nyc": "^17.0.0", "rewire": "^7.0.0", - "sinon": "^18.0.0", + "sinon": "^19.0.2", "yargs": "^17.7.2" }, "dependencies": { - "@alertlogic/al-aws-collector-js": "4.1.26", - "@smithy/node-http-handler":"3.1.3", + "@alertlogic/al-aws-collector-js": "^4.1.28", + "@smithy/node-http-handler": "^3.2.4", "async": "^3.2.5", "datadog-lambda-js": "^9.112.0", "debug": "^4.3.5", diff --git a/paws_collector.js b/paws_collector.js index 247f1217..a47c9c18 100644 --- a/paws_collector.js +++ b/paws_collector.js @@ -68,10 +68,14 @@ const nodeHttpHandler = new NodeHttpHandler({ httpsAgent: new https.Agent(agent) }); + const DDB_OPTIONS = { - maxAttempts: 10, + maxAttempts: 5, requestHandler: nodeHttpHandler } + +const DDB = new DynamoDB(DDB_OPTIONS); + const DDB_DELETE_BATCH_OPTIONS = { maxBatchSize: 25, maxBatchSizeBytes: 16 * 1024 * 1024 @@ -373,8 +377,6 @@ class PawsCollector extends AlAwsCollector { // there is a lot of logic here. not sur eif there is a better way of deduping. trying for an MVP checkStateSqsMessage(stateSqsMsg, asyncCallback) { const collector = this; - const DDB = new DynamoDB(DDB_OPTIONS); - const params = { Key: { "CollectorId": {S: collector._collectorId}, @@ -432,8 +434,6 @@ class PawsCollector extends AlAwsCollector { updateStateDBEntry(stateSqsMsg, Status, asyncCallback) { const collector = this; - const DDB = new DynamoDB(DDB_OPTIONS); - const updateParams = { Key: { CollectorId: {S: collector._collectorId}, @@ -941,7 +941,6 @@ class PawsCollector extends AlAwsCollector { */ removeDuplicatedItem(logs, paramName, asyncCallback) { let collector = this; - const ddb = new DynamoDB(DDB_OPTIONS); let uniqueLogs = []; var promises = []; let duplicateCount = 0; @@ -958,7 +957,7 @@ class PawsCollector extends AlAwsCollector { ConditionExpression: 'attribute_not_exists(Id)' }; let promise = new Promise((resolve, reject) => { - ddb.putItem(params, (err, res) => { + DDB.putItem(params, (err, res) => { if (err) { if (err.name === 'ConditionalCheckFailedException') { duplicateCount++; @@ -1063,9 +1062,8 @@ class PawsCollector extends AlAwsCollector { * @returns */ dDBBatchWriteItem(tableName, batch) { - const ddb = new DynamoDB(DDB_OPTIONS); const batchParams = { RequestItems: { [tableName]: batch } }; - return ddb.batchWriteItem(batchParams); + return DDB.batchWriteItem(batchParams); } /**