@middy/cloudwatch-metrics 7.6.5 → 7.6.7
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.
- package/README.md +1 -1
- package/index.js +13 -0
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
<a href="https://biomejs.dev"><img alt="Checked with Biome" src="https://img.shields.io/badge/Checked_with-Biome-60a5fa?style=flat&logo=biome"></a>
|
|
23
23
|
<a href="https://conventionalcommits.org"><img alt="Conventional Commits" src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white"></a>
|
|
24
24
|
<a href="https://github.com/middyjs/middy/blob/main/package.json#L32">
|
|
25
|
-
<img alt="code coverage" src="https://img.shields.io/badge/code%20coverage-
|
|
25
|
+
<img alt="code coverage" src="https://img.shields.io/badge/code%20coverage-100%25-brightgreen"></a>
|
|
26
26
|
</p>
|
|
27
27
|
<p>You can read the documentation at: <a href="https://middy.js.org/docs/middlewares/cloudwatch-metrics">https://middy.js.org/docs/middlewares/cloudwatch-metrics</a></p>
|
|
28
28
|
</div>
|
package/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import awsEmbeddedMetrics from "aws-embedded-metrics";
|
|
|
7
7
|
const name = "cloudwatch-metrics";
|
|
8
8
|
const pkg = `@middy/${name}`;
|
|
9
9
|
|
|
10
|
+
// Stryker disable next-line ObjectLiteral: value is already undefined, so dropping the key is observably identical after spread + destructuring
|
|
10
11
|
const defaults = {
|
|
11
12
|
onFlushError: undefined,
|
|
12
13
|
};
|
|
@@ -37,6 +38,18 @@ export const cloudwatchMetricsValidateOptions = (options) =>
|
|
|
37
38
|
|
|
38
39
|
const cloudwatchMetricsMiddleware = (opts = {}) => {
|
|
39
40
|
const { namespace, dimensions, onFlushError } = { ...defaults, ...opts };
|
|
41
|
+
|
|
42
|
+
if (dimensions) {
|
|
43
|
+
const dimensionSets = Array.isArray(dimensions) ? dimensions : [dimensions];
|
|
44
|
+
for (const set of dimensionSets) {
|
|
45
|
+
if (Object.keys(set).length > 30) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
`${pkg} a dimension set may contain at most 30 dimensions`,
|
|
48
|
+
{ cause: { package: pkg } },
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
40
53
|
const cloudwatchMetricsBefore = async (request) => {
|
|
41
54
|
const metrics = awsEmbeddedMetrics.createMetricsLogger();
|
|
42
55
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/cloudwatch-metrics",
|
|
3
|
-
"version": "7.6.
|
|
3
|
+
"version": "7.6.7",
|
|
4
4
|
"description": "Embedded CloudWatch metrics middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"test": "npm run test:unit && npm run test:fuzz",
|
|
30
30
|
"test:unit": "node --experimental-test-module-mocks --test",
|
|
31
31
|
"test:fuzz": "node --experimental-test-module-mocks --test index.fuzz.js",
|
|
32
|
-
"test:perf": "node --test index.perf.js"
|
|
32
|
+
"test:perf": "node --test index.perf.js",
|
|
33
|
+
"test:mutation": "cd ../.. && MUTATE_PACKAGE=\"$(basename \"$OLDPWD\")\" stryker run"
|
|
33
34
|
},
|
|
34
35
|
"license": "MIT",
|
|
35
36
|
"keywords": [
|
|
@@ -65,10 +66,11 @@
|
|
|
65
66
|
"url": "https://github.com/sponsors/willfarrell"
|
|
66
67
|
},
|
|
67
68
|
"dependencies": {
|
|
69
|
+
"@middy/util": "7.6.7",
|
|
68
70
|
"aws-embedded-metrics": "4.2.1"
|
|
69
71
|
},
|
|
70
72
|
"devDependencies": {
|
|
71
|
-
"@middy/core": "7.6.
|
|
73
|
+
"@middy/core": "7.6.7",
|
|
72
74
|
"@types/aws-lambda": "^8.0.0",
|
|
73
75
|
"@types/node": "^22.0.0"
|
|
74
76
|
}
|