@middy/cloudwatch-metrics
Advanced tools
Comparing version 3.0.0-alpha.2 to 3.0.0-alpha.3
38
index.js
@@ -1,35 +0,33 @@ | ||
import awsEmbeddedMetrics from 'aws-embedded-metrics'; | ||
import awsEmbeddedMetrics from 'aws-embedded-metrics' | ||
const defaults = {} | ||
const cloudwatchMetricsMiddleware = (opts = {}) => { | ||
const defaults = {}; | ||
const options = { ...defaults, | ||
...opts | ||
}; | ||
const options = { ...defaults, ...opts } | ||
const cloudwatchMetricsBefore = request => { | ||
const metrics = awsEmbeddedMetrics.createMetricsLogger(); | ||
const cloudwatchMetricsBefore = (request) => { | ||
const metrics = awsEmbeddedMetrics.createMetricsLogger() | ||
// If not set, defaults to aws-embedded-metrics | ||
if (options.namespace) { | ||
metrics.setNamespace(options.namespace); | ||
metrics.setNamespace(options.namespace) | ||
} | ||
// If not set, defaults to ServiceName, ServiceType and LogGroupName | ||
if (options.dimensions) { | ||
metrics.setDimensions(...options.dimensions); | ||
metrics.setDimensions(...options.dimensions) | ||
} | ||
Object.assign(request.context, { metrics }) | ||
} | ||
Object.assign(request.context, { | ||
metrics | ||
}); | ||
}; | ||
const cloudwatchMetricsAfter = async (request) => { | ||
await request.context.metrics.flush() | ||
} | ||
const cloudwatchMetricsAfter = async request => { | ||
await request.context.metrics.flush(); | ||
}; | ||
return { | ||
before: cloudwatchMetricsBefore, | ||
after: cloudwatchMetricsAfter | ||
}; | ||
}; | ||
} | ||
} | ||
export default cloudwatchMetricsMiddleware; | ||
export default cloudwatchMetricsMiddleware |
{ | ||
"name": "@middy/cloudwatch-metrics", | ||
"version": "3.0.0-alpha.2", | ||
"version": "3.0.0-alpha.3", | ||
"description": "Embedded CloudWatch metrics middleware for the middy framework", | ||
@@ -21,3 +21,4 @@ "type": "module", | ||
"test": "npm run test:unit", | ||
"test:unit": "ava" | ||
"test:unit": "ava", | ||
"test:benchmark": "node __benchmarks__/index.js" | ||
}, | ||
@@ -57,5 +58,5 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@middy/core": "^3.0.0-alpha.2" | ||
"@middy/core": "^3.0.0-alpha.3" | ||
}, | ||
"gitHead": "de30419273ecbff08f367f47c7e320ec981cf145" | ||
"gitHead": "1441158711580313765e6d156046ef0fade0d156" | ||
} |
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
7678
33