@middy/cloudwatch-metrics 4.0.0 → 4.0.2
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 +0 -54
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -36,60 +36,6 @@
|
|
|
36
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>
|
|
37
37
|
</div>
|
|
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.
|
|
40
|
-
|
|
41
|
-
Metrics collected with this logger are then available for querying within [AWS CloudWatch Log Insights](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AnalyzingLogData.html)
|
|
42
|
-
|
|
43
|
-
You can explore all the MetricLogger APIs following [aws-embedded-metrics](https://github.com/awslabs/aws-embedded-metrics-node) documentation.
|
|
44
|
-
|
|
45
|
-
## Install
|
|
46
|
-
|
|
47
|
-
To install this middleware you can use NPM:
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
npm install --save @middy/cloudwatch-metrics
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## Options
|
|
54
|
-
|
|
55
|
-
- `namespace` (string) (default `aws-embedded-metrics`): Sets the CloudWatch [namespace](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Namespace) that extracted metrics should be published to.
|
|
56
|
-
- `dimensions` (Record<String, String>[]): Defaults to
|
|
57
|
-
```json
|
|
58
|
-
[
|
|
59
|
-
{"ServiceName": "myLambdaFunctionName"},
|
|
60
|
-
{"ServiceType": "AWS::Lambda::Function"},
|
|
61
|
-
{"LogGroupName": "logGroupNameUsedByMyLambda"},
|
|
62
|
-
]
|
|
63
|
-
```
|
|
64
|
-
Explicitly override all dimensions. This will remove the default dimensions. You can provide an empty array to record all metrics without dimensions.
|
|
65
|
-
|
|
66
|
-
## Sample usage
|
|
67
|
-
|
|
68
|
-
```javascript
|
|
69
|
-
import middy from '@middy/core'
|
|
70
|
-
import cloudwatchMetrics from '@middy/cloudwatch-metrics'
|
|
71
|
-
|
|
72
|
-
const handler = middy((event, context) => {
|
|
73
|
-
context.metrics.putMetric("ProcessingLatency", 100, "Milliseconds");
|
|
74
|
-
context.metrics.setProperty("RequestId", "422b1569-16f6-4a03-b8f0-fe3fd9b100f8")
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
handler.use(cloudwatchMetrics({
|
|
78
|
-
namespace: "myAppliction",
|
|
79
|
-
dimensions: [
|
|
80
|
-
{ "Action": "Buy" }
|
|
81
|
-
]
|
|
82
|
-
}))
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
## Middy documentation and examples
|
|
86
|
-
|
|
87
|
-
For more documentation and examples, refers to the main [Middy monorepo on GitHub](https://github.com/middyjs/middy) or [Middy official website](https://middy.js.org).
|
|
88
|
-
|
|
89
|
-
## Contributing
|
|
90
|
-
|
|
91
|
-
Everyone is very welcome to contribute to this repository. Feel free to [raise issues](https://github.com/middyjs/middy/issues) or to [submit Pull Requests](https://github.com/middyjs/middy/pulls).
|
|
92
|
-
|
|
93
39
|
## License
|
|
94
40
|
|
|
95
41
|
Licensed under [MIT License](LICENSE). Copyright (c) 2017-2018 Luciano Mammino and the [Middy team](https://github.com/middyjs/middy/graphs/contributors).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/cloudwatch-metrics",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Embedded CloudWatch metrics middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
"aws-embedded-metrics": "4.0.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@middy/core": "4.0.
|
|
71
|
+
"@middy/core": "4.0.2",
|
|
72
72
|
"@types/aws-lambda": "^8.10.101"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "c77c9413ecb80999a71b67ff97edac1fed2ca754"
|
|
75
75
|
}
|