cat-a-logs 2.0.4 → 2.0.5
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/client/index.ts +8 -8
- package/package.json +1 -1
package/client/index.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Logger } from "@aws-lambda-powertools/logger";
|
2
2
|
import { Ajv } from "ajv";
|
3
3
|
|
4
|
-
//cache entries are structured thusly: 'Namespace +
|
4
|
+
//cache entries are structured thusly: 'Namespace + DimensionsKeys(Alphabetically)': EMFObject
|
5
5
|
const cache: { [key: string]: any } = {};
|
6
6
|
//let latency = 300; (Example metric to track)
|
7
7
|
//Example for in-line use of Cat-a-log w/maximum arguments: catalog(latency, "Latency" , "lambda-function-metrics", "Milliseconds", {'functionVersion': '$LATEST', 'Server': 'Prod'}, 60, deploy);
|
@@ -25,7 +25,7 @@ async function catalog(
|
|
25
25
|
if(badKeys.includes(yourKeys[i])){
|
26
26
|
//if a dimension name or metric name conflicts with native logger keys, throw error
|
27
27
|
throw new Error(
|
28
|
-
"metricName, or Dimension names
|
28
|
+
"metricName, or Dimension names CANNOT be the same as these native Logger keys: level || message || sampling_rate || service || timestamp || xray_trace_id"
|
29
29
|
);
|
30
30
|
}
|
31
31
|
}
|
@@ -37,11 +37,11 @@ async function catalog(
|
|
37
37
|
throw new Error("metric value cannot have more than 100 elements");
|
38
38
|
}
|
39
39
|
//EMF specification catch: make sure provided dimension object does not have more than 30 entries
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
if (Object.keys(CustomerDefinedDimension).length > 30) {
|
41
|
+
throw new Error(
|
42
|
+
"EMF has a limit of 30 user defined dimension keys per log"
|
43
|
+
);
|
44
|
+
}
|
45
45
|
//Create new instance of Logger to use in function
|
46
46
|
const logger = new Logger({ serviceName: "serverlessAirline" });
|
47
47
|
//Set up Ajv instance for JSON validation
|
@@ -230,7 +230,7 @@ async function catalog(
|
|
230
230
|
);
|
231
231
|
}
|
232
232
|
//clear cache after logging all cached objects to Lambda
|
233
|
-
console.log("BEFORE:", cache);
|
233
|
+
console.log("BEFORE:", JSON.stringify(cache, null, 2));
|
234
234
|
for (var member in cache) delete cache[member];
|
235
235
|
console.log("AFTER:", cache);
|
236
236
|
}
|