Skip to content

Commit

Permalink
fix(metrics): fix metrics lambda exit before completion
Browse files Browse the repository at this point in the history
  • Loading branch information
wyvern8 committed Jul 16, 2018
1 parent 299be98 commit 26bcf09
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"sls-undeploy": "node --require ./dotenv.js ./node_modules/serverless/bin/serverless remove",
"sls-logs-hook": "node --require ./dotenv.js ./node_modules/serverless/bin/serverless logs -f gtmGithubHook -t",
"sls-logs-results": "node --require ./dotenv.js ./node_modules/serverless/bin/serverless logs -f gtmGithubResults -t",
"sls-logs-metrics": "node --require ./dotenv.js ./node_modules/serverless/bin/serverless logs -f gtmGithubMetricCapture -t",
"sls-encrypt": "chmod 755 ./encrypt.sh && ./encrypt.sh",
"sls-decrypt": "node --require ./dotenv.js ./node_modules/serverless/bin/serverless decrypt -n",
"agent": "export $(cat .env | grep -v ^# | xargs) && node dist/src/agent/startAgent.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ AWS.config.update({ region: process.env.GTM_AWS_REGION });

const zlib = require('zlib');

async function handler(event, context, callback) {
function handler(event, context, callback) {
if (process.env.IAM_ENABLED) {
AWS.config.update({
httpOptions: {
Expand Down Expand Up @@ -57,7 +57,7 @@ async function handler(event, context, callback) {

let promises = [];

payload.logEvents.forEach(evt => {
payload.logEvents.forEach(async evt => {
let msg;
let isObj = true;
try {
Expand Down Expand Up @@ -184,7 +184,9 @@ async function handler(event, context, callback) {
});

Promise.all(promises).then(() => {
callback(null, `Successfully processed ${payload.logEvents.length} log events.`);
let message = `Successfully processed ${payload.logEvents.length} log events.`;
console.log(message);
callback(null, message);
});
});
}
Expand Down

0 comments on commit 26bcf09

Please sign in to comment.