lambda-log-wrapper
Advanced tools
Comparing version
11
index.js
@@ -13,6 +13,6 @@ 'use strict'; | ||
invoke(functionName, event) { | ||
invoke(event) { | ||
return new Promise((resolve, reject) => { | ||
var caller = { | ||
FunctionName: this.context.fucntionName, | ||
FunctionName: this.context.functionName, | ||
RequestId: this.context.awsRequestId | ||
@@ -25,5 +25,6 @@ //The ARN used to invoke this function (not sure of it's use/value) | ||
const request = { | ||
FunctionName: functionName, | ||
FunctionName: event.functionName, | ||
InvocationType: 'RequestResponse', | ||
Payload: JSON.stringify(event) | ||
Payload: JSON.stringify(event), | ||
LogType: 'Tail' | ||
}; | ||
@@ -52,3 +53,3 @@ | ||
{ | ||
MetricName: this.context.fucntionName+'/'+functionName, | ||
MetricName: this.context.fucntionName+'/'+event.functionName, | ||
Timestamp: new Date(), | ||
@@ -55,0 +56,0 @@ Unit: 'Milliseconds', |
{ | ||
"name": "lambda-log-wrapper", | ||
"version": "0.0.1", | ||
"description": "This is wrapper around node lambda which calls and logs ", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/paulSambolin/lambda-log-wrapper.git" | ||
}, | ||
"keywords": [ | ||
"lambda", | ||
"wrapper", | ||
"logging", | ||
"log", | ||
"monitor", | ||
"monitoring" | ||
], | ||
"author": "Paul Sambolin", | ||
"dependencies": { | ||
"aws-sdk": "^2.1.34" | ||
}, | ||
"devDependencies": { | ||
"babel-eslint": "*", | ||
"chai": "*", | ||
"eslint": "*", | ||
"eslint-plugin-react": "^4.3.0", | ||
"eslint-config-airbnb": "7.0.0", | ||
"grunt": "~0.4.5", | ||
"grunt-aws-lambda": "*", | ||
"grunt-mocha-test": "*", | ||
"mocha": "*" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/paulSambolin/lambda-log-wrapper/issues" | ||
}, | ||
"homepage": "https://github.com/paulSambolin/lambda-log-wrapper#readme" | ||
} | ||
"name": "lambda-log-wrapper", | ||
"version": "0.0.2", | ||
"description": "This is wrapper around node lambda which calls and logs ", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/paulSambolin/lambda-log-wrapper.git" | ||
}, | ||
"keywords": [ | ||
"lambda", | ||
"wrapper", | ||
"logging", | ||
"log", | ||
"monitor", | ||
"monitoring" | ||
], | ||
"author": "Paul Sambolin", | ||
"dependencies": { | ||
"aws-sdk": "^2.1.34" | ||
}, | ||
"devDependencies": { | ||
"babel-eslint": "*", | ||
"chai": "*", | ||
"eslint": "*", | ||
"eslint-plugin-react": "^4.3.0", | ||
"eslint-config-airbnb": "7.0.0", | ||
"grunt": "~0.4.5", | ||
"grunt-aws-lambda": "*", | ||
"grunt-mocha-test": "*", | ||
"mocha": "*" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/paulSambolin/lambda-log-wrapper/issues" | ||
}, | ||
"homepage": "https://github.com/paulSambolin/lambda-log-wrapper#readme" | ||
} |
@@ -45,13 +45,20 @@ ## Lambda Logger | ||
var request = { | ||
FunctionName: 'Helloworld', | ||
ProcessId: pid, | ||
TranactionId: tid | ||
}; | ||
lambda.invoke('Helloworld', request); | ||
lambda.invoke(request); | ||
// Micro-services should return: | ||
{ | ||
RequestId: rid, | ||
FunctionVersion: fv | ||
//additional data?? | ||
} | ||
// Chaining calls | ||
lambda.invoke(request) | ||
.then((response) => { | ||
// Do work ... | ||
return lambda.invoke(); | ||
}) | ||
.then(() => { | ||
// Do final steps | ||
}) | ||
.catch((err) => { | ||
// Error within promsise chain | ||
}); | ||
``` |
6384
0.57%96
1.05%64
12.28%