@emartech/aggregate-metric-logger 6.6.2 → 6.7.1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emartech/aggregate-metric-logger",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.7.1",
|
|
4
4
|
"description": "aggregate metrics in memory for logging",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -31,16 +31,16 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@emartech/json-logger": "9.2.5",
|
|
34
|
-
"@google-cloud/monitoring": "6.
|
|
34
|
+
"@google-cloud/monitoring": "6.2.0",
|
|
35
35
|
"json-stable-stringify": "1.3.0",
|
|
36
36
|
"lodash": "4.18.1",
|
|
37
37
|
"ms": "2.1.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@emartech/rti-server-tools": "11.
|
|
40
|
+
"@emartech/rti-server-tools": "11.22.0",
|
|
41
41
|
"@types/jest": "30.0.0",
|
|
42
42
|
"dotenv-haphap": "3.1.2",
|
|
43
|
-
"eslint": "10.
|
|
43
|
+
"eslint": "10.13.0",
|
|
44
44
|
"globals": "17.13.0",
|
|
45
45
|
"jest": "30.5.2",
|
|
46
46
|
"semantic-release": "25.0.9"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.createCounter = () => {
|
|
4
4
|
let count = 0;
|
|
5
|
-
|
|
5
|
+
let startTime = Date.now() - 1000;
|
|
6
6
|
|
|
7
7
|
return {
|
|
8
8
|
getState: () => ({
|
|
@@ -13,6 +13,8 @@ exports.createCounter = () => {
|
|
|
13
13
|
value: { int64Value: `${count}` }
|
|
14
14
|
}),
|
|
15
15
|
add: value => (count += value),
|
|
16
|
-
advanceTimer: () => {
|
|
16
|
+
advanceTimer: () => {
|
|
17
|
+
startTime = Date.now();
|
|
18
|
+
}
|
|
17
19
|
};
|
|
18
20
|
};
|
|
@@ -43,11 +43,23 @@ describe('count', () => {
|
|
|
43
43
|
|
|
44
44
|
expect(counter.getState()).toMatchObject({
|
|
45
45
|
value: { int64Value: '3' },
|
|
46
|
-
startTime:
|
|
46
|
+
startTime: 8900,
|
|
47
47
|
endTime: 8900
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
+
it('should advance startTime on advanceTimer so successive GCP writes are in order', () => {
|
|
52
|
+
jest.useFakeTimers().setSystemTime(new Date(8880));
|
|
53
|
+
const counter = createCounter();
|
|
54
|
+
|
|
55
|
+
const firstStartTime = counter.getState().startTime;
|
|
56
|
+
jest.advanceTimersByTime(60000);
|
|
57
|
+
counter.advanceTimer();
|
|
58
|
+
const secondStartTime = counter.getState().startTime;
|
|
59
|
+
|
|
60
|
+
expect(secondStartTime).toBeGreaterThan(firstStartTime);
|
|
61
|
+
});
|
|
62
|
+
|
|
51
63
|
it('should return current time as endTime', () => {
|
|
52
64
|
jest.useFakeTimers().setSystemTime(new Date(880));
|
|
53
65
|
const counter = createCounter();
|