@middy/cloudwatch-metrics 3.0.0-alpha.3 → 3.0.0-alpha.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.
Files changed (3) hide show
  1. package/README.md +24 -17
  2. package/index.js +2 -32
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -1,29 +1,36 @@
1
- # Middy Cloudwatch metrics middleware
2
-
3
- <div align="center">
4
- <img alt="Middy logo" src="https://raw.githubusercontent.com/middyjs/middy/master/img/middy-logo.png"/>
5
- </div>
6
-
7
1
  <div align="center">
2
+ <h1>Middy CloudWatch metrics middleware</h1>
3
+ <img alt="Middy logo" src="https://raw.githubusercontent.com/middyjs/middy/main/img/middy-logo.svg"/>
8
4
  <p><strong>Metrics middleware for the middy framework, the stylish Node.js middleware engine for AWS Lambda</strong></p>
9
- </div>
10
-
11
- <div align="center">
12
5
  <p>
13
- <a href="http://badge.fury.io/js/%40middy%2Fcloudwatch-metrics">
6
+ <a href="https://www.npmjs.com/package/@middy/cloudwatch-metrics?activeTab=versions">
14
7
  <img src="https://badge.fury.io/js/%40middy%2Fcloudwatch-metrics.svg" alt="npm version" style="max-width:100%;">
15
8
  </a>
9
+ <a href="https://packagephobia.com/result?p=@middy/cloudwatch-metrics">
10
+ <img src="https://packagephobia.com/badge?p=@middy/cloudwatch-metrics" alt="npm install size" style="max-width:100%;">
11
+ </a>
12
+ <a href="https://github.com/middyjs/middy/actions">
13
+ <img src="https://github.com/middyjs/middy/workflows/Tests/badge.svg" alt="GitHub Actions test status badge" style="max-width:100%;">
14
+ </a>
15
+ <br/>
16
+ <a href="https://standardjs.com/">
17
+ <img src="https://img.shields.io/badge/code_style-standard-brightgreen.svg" alt="Standard Code Style" style="max-width:100%;">
18
+ </a>
16
19
  <a href="https://snyk.io/test/github/middyjs/middy">
17
20
  <img src="https://snyk.io/test/github/middyjs/middy/badge.svg" alt="Known Vulnerabilities" data-canonical-src="https://snyk.io/test/github/middyjs/middy" style="max-width:100%;">
18
21
  </a>
19
- <a href="https://standardjs.com/">
20
- <img src="https://img.shields.io/badge/code_style-standard-brightgreen.svg" alt="Standard Code Style" style="max-width:100%;">
22
+ <a href="https://lgtm.com/projects/g/middyjs/middy/context:javascript">
23
+ <img src="https://img.shields.io/lgtm/grade/javascript/g/middyjs/middy.svg?logo=lgtm&logoWidth=18" alt="Language grade: JavaScript" style="max-width:100%;">
21
24
  </a>
22
- <a href="https://greenkeeper.io/">
23
- <img src="https://badges.greenkeeper.io/middyjs/middy.svg" alt="Greenkeeper badge" style="max-width:100%;">
25
+ <a href="https://bestpractices.coreinfrastructure.org/projects/5280">
26
+ <img src="https://bestpractices.coreinfrastructure.org/projects/5280/badge" alt="Core Infrastructure Initiative (CII) Best Practices" style="max-width:100%;">
24
27
  </a>
28
+ <br/>
25
29
  <a href="https://gitter.im/middyjs/Lobby">
26
- <img src="https://badges.gitter.im/gitterHQ/gitter.svg" alt="Chat on Gitter" style="max-width:100%;">
30
+ <img src="https://badges.gitter.im/gitterHQ/gitter.svg" alt="Chat on Gitter" style="max-width:100%;">
31
+ </a>
32
+ <a href="https://stackoverflow.com/questions/tagged/middy?sort=Newest&uqlId=35052">
33
+ <img src="https://img.shields.io/badge/StackOverflow-[middy]-yellow" alt="Ask questions on StackOverflow" style="max-width:100%;">
27
34
  </a>
28
35
  </p>
29
36
  </div>
@@ -44,8 +51,8 @@ npm install --save @middy/cloudwatch-metrics
44
51
 
45
52
  ## Options
46
53
 
47
- - `namespace` (string) (optional): Defaults to `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.
48
- - `dimensions` (Record<String, String>[]) (optional): Defaults to
54
+ - `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.
55
+ - `dimensions` (Record<String, String>[]): Defaults to
49
56
  ```json
50
57
  [
51
58
  {"ServiceName": "myLambdaFunctionName"},
package/index.js CHANGED
@@ -1,33 +1,3 @@
1
- import awsEmbeddedMetrics from 'aws-embedded-metrics'
1
+ 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
2
2
 
3
- const defaults = {}
4
-
5
- const cloudwatchMetricsMiddleware = (opts = {}) => {
6
- const options = { ...defaults, ...opts }
7
-
8
- const cloudwatchMetricsBefore = (request) => {
9
- const metrics = awsEmbeddedMetrics.createMetricsLogger()
10
-
11
- // If not set, defaults to aws-embedded-metrics
12
- if (options.namespace) {
13
- metrics.setNamespace(options.namespace)
14
- }
15
-
16
- // If not set, defaults to ServiceName, ServiceType and LogGroupName
17
- if (options.dimensions) {
18
- metrics.setDimensions(...options.dimensions)
19
- }
20
- Object.assign(request.context, { metrics })
21
- }
22
-
23
- const cloudwatchMetricsAfter = async (request) => {
24
- await request.context.metrics.flush()
25
- }
26
-
27
- return {
28
- before: cloudwatchMetricsBefore,
29
- after: cloudwatchMetricsAfter
30
- }
31
- }
32
-
33
- export default cloudwatchMetricsMiddleware
3
+ //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/cloudwatch-metrics",
3
- "version": "3.0.0-alpha.3",
3
+ "version": "3.0.0-alpha.7",
4
4
  "description": "Embedded CloudWatch metrics middleware for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -54,7 +54,7 @@
54
54
  "aws-embedded-metrics": "2.0.4"
55
55
  },
56
56
  "devDependencies": {
57
- "@middy/core": "^3.0.0-alpha.3"
57
+ "@middy/core": "^3.0.0-alpha.7"
58
58
  },
59
- "gitHead": "1441158711580313765e6d156046ef0fade0d156"
59
+ "gitHead": "5cef39ebe49c201f97d71bb0680004de4b82cb91"
60
60
  }