@emartech/aggregate-metric-logger 3.3.0 → 3.3.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.
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
name: Aggregate Metric Logger Build
|
|
2
|
+
|
|
3
|
+
on: push
|
|
4
|
+
|
|
5
|
+
env:
|
|
6
|
+
NPM_TOKEN: ${{ secrets.NPM_PUBLISHER_TOKEN }}
|
|
7
|
+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
8
|
+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
test:
|
|
12
|
+
name: Tests 🚦
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- name: Check out repository
|
|
16
|
+
uses: actions/checkout@v3
|
|
17
|
+
- name: Use correct Node version
|
|
18
|
+
uses: actions/setup-node@v3
|
|
19
|
+
with:
|
|
20
|
+
node-version-file: '.nvmrc'
|
|
21
|
+
- name: Cache node_modules
|
|
22
|
+
id: cache_node_modules
|
|
23
|
+
uses: actions/cache@v3
|
|
24
|
+
with:
|
|
25
|
+
path: node_modules
|
|
26
|
+
key: node_modules-${{ hashFiles('**/package-lock.json') }}
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
if: ${{ steps.cache_node_modules.outputs.cache-hit != 'true' }}
|
|
29
|
+
continue-on-error: true
|
|
30
|
+
run: |
|
|
31
|
+
npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN
|
|
32
|
+
npm i
|
|
33
|
+
- name: Run tests
|
|
34
|
+
run: npm test
|
|
35
|
+
- name: Slack notification
|
|
36
|
+
uses: 8398a7/action-slack@a189acbf0b7ea434558662ae25a0de71df69a435
|
|
37
|
+
if: ${{ failure() }}
|
|
38
|
+
with:
|
|
39
|
+
status: ${{ job.status }}
|
|
40
|
+
fields: repo,message,author,job,ref
|
|
41
|
+
job_name: Test 🚦
|
|
42
|
+
env:
|
|
43
|
+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
44
|
+
|
|
45
|
+
deploy:
|
|
46
|
+
name: Deploy 🚢
|
|
47
|
+
needs: [test]
|
|
48
|
+
runs-on: ubuntu-latest
|
|
49
|
+
steps:
|
|
50
|
+
- name: Check out repository
|
|
51
|
+
uses: actions/checkout@v3
|
|
52
|
+
- name: Use correct Node version
|
|
53
|
+
uses: actions/setup-node@v3
|
|
54
|
+
with:
|
|
55
|
+
node-version-file: '.nvmrc'
|
|
56
|
+
- name: Cache node_modules
|
|
57
|
+
id: cache_node_modules
|
|
58
|
+
uses: actions/cache@v3
|
|
59
|
+
with:
|
|
60
|
+
path: node_modules
|
|
61
|
+
key: node_modules-${{ hashFiles('**/package-lock.json') }}
|
|
62
|
+
- name: Release package
|
|
63
|
+
if: github.ref_name == 'master'
|
|
64
|
+
run: CI=true npm run semantic-release
|
|
65
|
+
- name: Slack notification
|
|
66
|
+
uses: 8398a7/action-slack@a189acbf0b7ea434558662ae25a0de71df69a435
|
|
67
|
+
with:
|
|
68
|
+
status: ${{ job.status }}
|
|
69
|
+
fields: repo,message,author,job,ref
|
|
70
|
+
job_name: Deploy 🚢
|
|
71
|
+
env:
|
|
72
|
+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
73
|
+
if: always()
|
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ const metricLogger = require('@emartech/aggregate-metric-logger')
|
|
|
34
34
|
metricLogger.warn('etwas-went-wrong', { customer_id: 11 });
|
|
35
35
|
metricLogger.warn('etwas-went-wrong', { customer_id: 11 });
|
|
36
36
|
|
|
37
|
-
// will
|
|
37
|
+
// will aggregate these to a single warning log
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
### Measure values
|
package/package.json
CHANGED
|
@@ -4,12 +4,12 @@ const { createCounter } = require('./counter');
|
|
|
4
4
|
|
|
5
5
|
describe('count', () => {
|
|
6
6
|
it('should return an empty counter if no values were added', () => {
|
|
7
|
-
jest.useFakeTimers().setSystemTime(new Date(
|
|
7
|
+
jest.useFakeTimers().setSystemTime(new Date(8880));
|
|
8
8
|
const counter = createCounter();
|
|
9
9
|
|
|
10
10
|
expect(counter.getState()).toEqual({
|
|
11
|
-
startTime:
|
|
12
|
-
endTime:
|
|
11
|
+
startTime: 7880,
|
|
12
|
+
endTime: 8880,
|
|
13
13
|
metricKind: 'CUMULATIVE',
|
|
14
14
|
valueType: 'int64Value',
|
|
15
15
|
value: { int64Value: '0' }
|
|
@@ -18,7 +18,7 @@ describe('count', () => {
|
|
|
18
18
|
|
|
19
19
|
it('should return with the startTime which is before the endTime even when no time passes', () => {
|
|
20
20
|
// which is a must-have for non-gauge metrics
|
|
21
|
-
jest.useFakeTimers().setSystemTime(new Date(
|
|
21
|
+
jest.useFakeTimers().setSystemTime(new Date(8880));
|
|
22
22
|
const counter = createCounter();
|
|
23
23
|
expect(counter.getState().endTime).toBeGreaterThan(counter.getState().startTime);
|
|
24
24
|
});
|
|
@@ -33,7 +33,7 @@ describe('count', () => {
|
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
it('should not reset the current count on advanceTimer call', () => {
|
|
36
|
-
jest.useFakeTimers().setSystemTime(new Date(
|
|
36
|
+
jest.useFakeTimers().setSystemTime(new Date(8880));
|
|
37
37
|
const counter = createCounter();
|
|
38
38
|
|
|
39
39
|
jest.advanceTimersByTime(20);
|
|
@@ -43,8 +43,8 @@ describe('count', () => {
|
|
|
43
43
|
|
|
44
44
|
expect(counter.getState()).toMatchObject({
|
|
45
45
|
value: { int64Value: '3' },
|
|
46
|
-
startTime:
|
|
47
|
-
endTime:
|
|
46
|
+
startTime: 7880,
|
|
47
|
+
endTime: 8900
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
50
|
|