@middy/cloudwatch-metrics
Advanced tools
Comparing version
30
index.js
@@ -1,3 +0,31 @@ | ||
import awsEmbeddedMetrics from"aws-embedded-metrics";const defaults={};const cloudwatchMetricsMiddleware=(opts={})=>{const options={...defaults,...opts};const cloudwatchMetricsBefore=request=>{const metrics=awsEmbeddedMetrics.createMetricsLogger();if(options.namespace){metrics.setNamespace(options.namespace)}if(options.dimensions){metrics.setDimensions(...options.dimensions)}Object.assign(request.context,{metrics})};const cloudwatchMetricsAfter=async request=>{await request.context.metrics.flush()};return{before:cloudwatchMetricsBefore,after:cloudwatchMetricsAfter}};export default cloudwatchMetricsMiddleware | ||
import awsEmbeddedMetrics from 'aws-embedded-metrics'; | ||
const defaults = {}; | ||
const cloudwatchMetricsMiddleware = (opts = {})=>{ | ||
const options = { | ||
...defaults, | ||
...opts | ||
}; | ||
const cloudwatchMetricsBefore = (request)=>{ | ||
const metrics = awsEmbeddedMetrics.createMetricsLogger(); | ||
if (options.namespace) { | ||
metrics.setNamespace(options.namespace); | ||
} | ||
if (options.dimensions) { | ||
metrics.setDimensions(...options.dimensions); | ||
} | ||
Object.assign(request.context, { | ||
metrics | ||
}); | ||
}; | ||
const cloudwatchMetricsAfter = async (request)=>{ | ||
await request.context.metrics.flush(); | ||
}; | ||
return { | ||
before: cloudwatchMetricsBefore, | ||
after: cloudwatchMetricsAfter | ||
}; | ||
}; | ||
export default cloudwatchMetricsMiddleware; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@middy/cloudwatch-metrics", | ||
"version": "3.0.3", | ||
"version": "3.0.4", | ||
"description": "Embedded CloudWatch metrics middleware for the middy framework", | ||
@@ -61,8 +61,8 @@ "type": "module", | ||
"dependencies": { | ||
"aws-embedded-metrics": "2.0.4" | ||
"aws-embedded-metrics": "2.0.5" | ||
}, | ||
"devDependencies": { | ||
"@middy/core": "3.0.3" | ||
"@middy/core": "3.0.4" | ||
}, | ||
"gitHead": "ea9e5e8cce754d0c467c7dd3ac9a7601149efea2" | ||
"gitHead": "3e9bc83e791f943c71cd7003fc27f0a3692d83a1" | ||
} |
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
10137
5.19%75
400%0
-100%+ Added
- Removed
Updated