@middy/cloudwatch-metrics 3.0.1 → 3.0.4
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/LICENSE +1 -1
- package/README.md +3 -2
- package/index.cjs +40 -1
- package/index.js +29 -1
- package/package.json +4 -4
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2017-2022 Luciano Mammino, will Farrell and the [Middy team](https://github.com/middyjs/middy/graphs/contributors)
|
|
3
|
+
Copyright (c) 2017-2022 [Luciano Mammino](https://github.com/lmammino), [will Farrell](https://github.com/willfarrell) and the [Middy team](https://github.com/middyjs/middy/graphs/contributors)
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
<a href="https://packagephobia.com/result?p=@middy/cloudwatch-metrics">
|
|
10
10
|
<img src="https://packagephobia.com/badge?p=@middy/cloudwatch-metrics" alt="npm install size" style="max-width:100%;">
|
|
11
11
|
</a>
|
|
12
|
-
<a href="https://github.com/middyjs/middy/actions">
|
|
13
|
-
<img src="https://github.com/middyjs/middy/workflows/
|
|
12
|
+
<a href="https://github.com/middyjs/middy/actions/workflows/tests.yml">
|
|
13
|
+
<img src="https://github.com/middyjs/middy/actions/workflows/tests.yml/badge.svg?branch=main&event=push" alt="GitHub Actions CI status badge" style="max-width:100%;">
|
|
14
14
|
</a>
|
|
15
15
|
<br/>
|
|
16
16
|
<a href="https://standardjs.com/">
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
<img src="https://img.shields.io/badge/StackOverflow-[middy]-yellow" alt="Ask questions on StackOverflow" style="max-width:100%;">
|
|
34
34
|
</a>
|
|
35
35
|
</p>
|
|
36
|
+
<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>
|
|
36
37
|
</div>
|
|
37
38
|
|
|
38
39
|
This middleware hydrates lambda's `context.metrics` property with an instance of [MetricLogger](https://github.com/awslabs/aws-embedded-metrics-node#metriclogger). This instance can be used to easily generate custom metrics from Lambda functions without requiring custom batching code, making blocking network requests or relying on 3rd party software.
|
package/index.cjs
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
module.exports = void 0;
|
|
6
|
+
var _awsEmbeddedMetrics = _interopRequireDefault(require("aws-embedded-metrics"));
|
|
7
|
+
function _interopRequireDefault(obj) {
|
|
8
|
+
return obj && obj.__esModule ? obj : {
|
|
9
|
+
default: obj
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
const defaults = {};
|
|
13
|
+
const cloudwatchMetricsMiddleware = (opts = {})=>{
|
|
14
|
+
const options = {
|
|
15
|
+
...defaults,
|
|
16
|
+
...opts
|
|
17
|
+
};
|
|
18
|
+
const cloudwatchMetricsBefore = (request)=>{
|
|
19
|
+
const metrics = _awsEmbeddedMetrics.default.createMetricsLogger();
|
|
20
|
+
if (options.namespace) {
|
|
21
|
+
metrics.setNamespace(options.namespace);
|
|
22
|
+
}
|
|
23
|
+
if (options.dimensions) {
|
|
24
|
+
metrics.setDimensions(...options.dimensions);
|
|
25
|
+
}
|
|
26
|
+
Object.assign(request.context, {
|
|
27
|
+
metrics
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
const cloudwatchMetricsAfter = async (request)=>{
|
|
31
|
+
await request.context.metrics.flush();
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
before: cloudwatchMetricsBefore,
|
|
35
|
+
after: cloudwatchMetricsAfter
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
var _default = cloudwatchMetricsMiddleware;
|
|
39
|
+
module.exports = _default;
|
|
40
|
+
|
|
2
41
|
|
|
3
42
|
//# sourceMappingURL=index.cjs.map
|
package/index.js
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
-
import awsEmbeddedMetrics from
|
|
1
|
+
import awsEmbeddedMetrics from 'aws-embedded-metrics';
|
|
2
|
+
const defaults = {};
|
|
3
|
+
const cloudwatchMetricsMiddleware = (opts = {})=>{
|
|
4
|
+
const options = {
|
|
5
|
+
...defaults,
|
|
6
|
+
...opts
|
|
7
|
+
};
|
|
8
|
+
const cloudwatchMetricsBefore = (request)=>{
|
|
9
|
+
const metrics = awsEmbeddedMetrics.createMetricsLogger();
|
|
10
|
+
if (options.namespace) {
|
|
11
|
+
metrics.setNamespace(options.namespace);
|
|
12
|
+
}
|
|
13
|
+
if (options.dimensions) {
|
|
14
|
+
metrics.setDimensions(...options.dimensions);
|
|
15
|
+
}
|
|
16
|
+
Object.assign(request.context, {
|
|
17
|
+
metrics
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const cloudwatchMetricsAfter = async (request)=>{
|
|
21
|
+
await request.context.metrics.flush();
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
before: cloudwatchMetricsBefore,
|
|
25
|
+
after: cloudwatchMetricsAfter
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export default cloudwatchMetricsMiddleware;
|
|
29
|
+
|
|
2
30
|
|
|
3
31
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/cloudwatch-metrics",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4",
|
|
4
4
|
"description": "Embedded CloudWatch metrics middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -58,10 +58,10 @@
|
|
|
58
58
|
},
|
|
59
59
|
"homepage": "https://middy.js.org",
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"aws-embedded-metrics": "2.0.
|
|
61
|
+
"aws-embedded-metrics": "2.0.5"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@middy/core": "
|
|
64
|
+
"@middy/core": "3.0.4"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "3e9bc83e791f943c71cd7003fc27f0a3692d83a1"
|
|
67
67
|
}
|