lambda-cloud-watch-log-parser
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -72,2 +72,16 @@ "use strict" | ||
/** | ||
* Calculates the cost of the function run. | ||
* | ||
* @sync | ||
* @method calculateLambdaCost | ||
* @param {Number} duration The length of time the function ran. This number should be in milliseconds. | ||
* @param {Number} function_size The size of the function that was ran. | ||
*/ | ||
LogParser.prototype.calculateFunctionCost = function (duration, function_size) { | ||
var cost_per_gb_sec = .00001667; | ||
return (cost_per_gb_sec / (1024 / function_size)) * (duration / 1000); | ||
}; | ||
/** | ||
* Takes the log data and parses it. | ||
@@ -131,7 +145,11 @@ * | ||
} | ||
if(usage.request_id === request_id){ | ||
log.usage.request_id = usage.request_id; | ||
log.usage.billed_duration = usage.billed_duration; | ||
log.usage.memory_size = usage.memory_size; | ||
log.usage.max_memory_size = usage.max_memory_size; | ||
log.usage.billed_duration = parseInt(usage.billed_duration.replace('ms', '').trim()); | ||
log.usage.memory_size = parseInt(usage.memory_size.replace('MB', '').trim()); | ||
log.usage.max_memory_size = parseInt(usage.max_memory_size.replace('MB', '').trim()); | ||
log.usage.cost = _this.calculateFunctionCost(log.usage.billed_duration, log.usage.memory_size); | ||
} | ||
@@ -138,0 +156,0 @@ } |
{ | ||
"name": "lambda-cloud-watch-log-parser", | ||
"description": "Parses event data from cloud watch logs.", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "dependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27253
129