@middy/cloudwatch-metrics 2.5.2 → 2.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +18 -24
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -1,38 +1,32 @@
1
- "use strict";
2
-
3
- const awsEmbeddedMetrics = require('aws-embedded-metrics');
1
+ const awsEmbeddedMetrics = require('aws-embedded-metrics')
4
2
 
5
3
  const cloudwatchMetricsMiddleware = (opts = {}) => {
6
- const defaults = {};
7
- const options = { ...defaults,
8
- ...opts
9
- };
4
+ const defaults = {}
5
+ const options = { ...defaults, ...opts }
10
6
 
11
- const cloudwatchMetricsBefore = request => {
12
- const metrics = awsEmbeddedMetrics.createMetricsLogger(); // If not set, defaults to aws-embedded-metrics
7
+ const cloudwatchMetricsBefore = (request) => {
8
+ const metrics = awsEmbeddedMetrics.createMetricsLogger()
13
9
 
10
+ // If not set, defaults to aws-embedded-metrics
14
11
  if (options.namespace) {
15
- metrics.setNamespace(options.namespace);
16
- } // If not set, defaults to ServiceName, ServiceType and LogGroupName
17
-
12
+ metrics.setNamespace(options.namespace)
13
+ }
18
14
 
15
+ // If not set, defaults to ServiceName, ServiceType and LogGroupName
19
16
  if (options.dimensions) {
20
- metrics.setDimensions(...options.dimensions);
17
+ metrics.setDimensions(...options.dimensions)
21
18
  }
19
+ Object.assign(request.context, { metrics })
20
+ }
22
21
 
23
- Object.assign(request.context, {
24
- metrics
25
- });
26
- };
27
-
28
- const cloudwatchMetricsAfter = async request => {
29
- await request.context.metrics.flush();
30
- };
22
+ const cloudwatchMetricsAfter = async (request) => {
23
+ await request.context.metrics.flush()
24
+ }
31
25
 
32
26
  return {
33
27
  before: cloudwatchMetricsBefore,
34
28
  after: cloudwatchMetricsAfter
35
- };
36
- };
29
+ }
30
+ }
37
31
 
38
- module.exports = cloudwatchMetricsMiddleware;
32
+ module.exports = cloudwatchMetricsMiddleware
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/cloudwatch-metrics",
3
- "version": "2.5.2",
3
+ "version": "2.5.6",
4
4
  "description": "Embedded CloudWatch metrics middleware for the middy framework",
5
5
  "type": "commonjs",
6
6
  "engines": {
@@ -52,7 +52,7 @@
52
52
  "aws-embedded-metrics": "2.0.4"
53
53
  },
54
54
  "devDependencies": {
55
- "@middy/core": "^2.5.2"
55
+ "@middy/core": "^2.5.6"
56
56
  },
57
- "gitHead": "a2bb757a7a13638ae64277f8eecfcf11c1af17d4"
57
+ "gitHead": "0c789f55b4adf691f977b0d9904d1a805bb3bb2b"
58
58
  }