@middy/cloudwatch-metrics
Advanced tools
Comparing version 3.0.0-alpha.3 to 3.0.0-alpha.4
38
index.js
@@ -1,33 +0,35 @@ | ||
import awsEmbeddedMetrics from 'aws-embedded-metrics' | ||
import awsEmbeddedMetrics from 'aws-embedded-metrics'; | ||
const defaults = {}; | ||
const defaults = {} | ||
const cloudwatchMetricsMiddleware = (opts = {}) => { | ||
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 }) | ||
} | ||
const cloudwatchMetricsAfter = async (request) => { | ||
await request.context.metrics.flush() | ||
} | ||
Object.assign(request.context, { | ||
metrics | ||
}); | ||
}; | ||
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.3", | ||
"version": "3.0.0-alpha.4", | ||
"description": "Embedded CloudWatch metrics middleware for the middy framework", | ||
@@ -57,5 +57,5 @@ "type": "module", | ||
"devDependencies": { | ||
"@middy/core": "^3.0.0-alpha.3" | ||
"@middy/core": "^3.0.0-alpha.4" | ||
}, | ||
"gitHead": "1441158711580313765e6d156046ef0fade0d156" | ||
"gitHead": "d4bea7f4e21f6a9bbb1f6f6908361169598b9e53" | ||
} |
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
35
7578