@middy/cloudwatch-metrics 2.5.4 → 3.0.0-alpha.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2017-2021 Luciano Mammino, will Farrell and the [Middy team](https://github.com/middyjs/middy/graphs/contributors)
3
+ Copyright (c) 2017-2022 Luciano Mammino, will Farrell 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
@@ -58,8 +58,8 @@ npm install --save @middy/cloudwatch-metrics
58
58
  ## Sample usage
59
59
 
60
60
  ```javascript
61
- const middy = require('@middy/core')
62
- const cloudwatchMetrics = require('@middy/cloudwatch-metrics')
61
+ import middy from '@middy/core'
62
+ import cloudwatchMetrics from '@middy/cloudwatch-metrics'
63
63
 
64
64
  const handler = middy((event, context) => {
65
65
  context.metrics.putMetric("ProcessingLatency", 100, "Milliseconds");
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@middy/cloudwatch-metrics",
3
- "version": "2.5.4",
3
+ "version": "3.0.0-alpha.0",
4
4
  "description": "Embedded CloudWatch metrics middleware for the middy framework",
5
- "type": "commonjs",
5
+ "type": "module",
6
6
  "engines": {
7
- "node": ">=12"
7
+ "node": ">=14"
8
8
  },
9
9
  "engineStrict": true,
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
13
- "main": "index.js",
13
+ "exports": "./index.js",
14
14
  "types": "index.d.ts",
15
15
  "files": [
16
16
  "index.d.ts"
@@ -52,7 +52,7 @@
52
52
  "aws-embedded-metrics": "2.0.4"
53
53
  },
54
54
  "devDependencies": {
55
- "@middy/core": "^2.5.4"
55
+ "@middy/core": "^3.0.0-alpha.0"
56
56
  },
57
- "gitHead": "a4134a579c757a9fdfed3006877ba2c0ec8a2cfa"
57
+ "gitHead": "c533f62841c8a39d061d7b94f30ba178f002c8db"
58
58
  }
package/index.js DELETED
@@ -1,38 +0,0 @@
1
- "use strict";
2
-
3
- const awsEmbeddedMetrics = require('aws-embedded-metrics');
4
-
5
- const cloudwatchMetricsMiddleware = (opts = {}) => {
6
- const defaults = {};
7
- const options = { ...defaults,
8
- ...opts
9
- };
10
-
11
- const cloudwatchMetricsBefore = request => {
12
- const metrics = awsEmbeddedMetrics.createMetricsLogger(); // If not set, defaults to aws-embedded-metrics
13
-
14
- if (options.namespace) {
15
- metrics.setNamespace(options.namespace);
16
- } // If not set, defaults to ServiceName, ServiceType and LogGroupName
17
-
18
-
19
- if (options.dimensions) {
20
- metrics.setDimensions(...options.dimensions);
21
- }
22
-
23
- Object.assign(request.context, {
24
- metrics
25
- });
26
- };
27
-
28
- const cloudwatchMetricsAfter = async request => {
29
- await request.context.metrics.flush();
30
- };
31
-
32
- return {
33
- before: cloudwatchMetricsBefore,
34
- after: cloudwatchMetricsAfter
35
- };
36
- };
37
-
38
- module.exports = cloudwatchMetricsMiddleware;