@webex/internal-plugin-metrics 3.0.0-beta.19 → 3.0.0-beta.190
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/dist/call-diagnostic/call-diagnostic-metrics-batcher.js +134 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-batcher.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js +451 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.js +511 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js +106 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js.map +1 -0
- package/dist/call-diagnostic/config.js +461 -0
- package/dist/call-diagnostic/config.js.map +1 -0
- package/dist/call-diagnostic/generated-types-temp/ClientEvent.js +7 -0
- package/dist/call-diagnostic/generated-types-temp/ClientEvent.js.map +1 -0
- package/dist/call-diagnostic/generated-types-temp/Event.js +7 -0
- package/dist/call-diagnostic/generated-types-temp/Event.js.map +1 -0
- package/dist/call-diagnostic/generated-types-temp/MediaQualityEvent.js +7 -0
- package/dist/call-diagnostic/generated-types-temp/MediaQualityEvent.js.map +1 -0
- package/dist/config.js +20 -1
- package/dist/config.js.map +1 -1
- package/dist/index.js +25 -1
- package/dist/index.js.map +1 -1
- package/dist/metrics.js +30 -30
- package/dist/metrics.js.map +1 -1
- package/dist/metrics.types.js +7 -0
- package/dist/metrics.types.js.map +1 -0
- package/dist/new-metrics.js +185 -0
- package/dist/new-metrics.js.map +1 -0
- package/dist/types/batcher.d.ts +2 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics-batcher.d.ts +2 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics-latencies.d.ts +189 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +324 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics.util.d.ts +31 -0
- package/dist/types/call-diagnostic/config.d.ts +57 -0
- package/dist/types/call-diagnostic/generated-types-temp/ClientEvent.d.ts +1112 -0
- package/dist/types/call-diagnostic/generated-types-temp/Event.d.ts +4851 -0
- package/dist/types/call-diagnostic/generated-types-temp/MediaQualityEvent.d.ts +2121 -0
- package/dist/types/client-metrics-batcher.d.ts +2 -0
- package/dist/types/config.d.ts +35 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/metrics.d.ts +3 -0
- package/dist/types/metrics.types.d.ts +87 -0
- package/dist/types/new-metrics.d.ts +83 -0
- package/package.json +12 -8
- package/src/call-diagnostic/call-diagnostic-metrics-batcher.ts +148 -0
- package/src/call-diagnostic/call-diagnostic-metrics-latencies.ts +408 -0
- package/src/call-diagnostic/call-diagnostic-metrics.ts +528 -0
- package/src/call-diagnostic/call-diagnostic-metrics.util.ts +102 -0
- package/src/call-diagnostic/config.ts +455 -0
- package/src/call-diagnostic/generated-types-temp/ClientEvent.ts +2357 -0
- package/src/call-diagnostic/generated-types-temp/Event.ts +7669 -0
- package/src/call-diagnostic/generated-types-temp/MediaQualityEvent.ts +2321 -0
- package/src/config.js +19 -0
- package/src/index.ts +39 -0
- package/src/metrics.js +25 -27
- package/src/metrics.types.ts +131 -0
- package/src/new-metrics.ts +170 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +243 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-latencies.ts +474 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +722 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +76 -0
- package/test/unit/spec/metrics.js +65 -97
- package/test/unit/spec/new-metrics.ts +91 -0
- package/tsconfig.json +6 -0
- package/dist/call-diagnostic-events-batcher.js +0 -60
- package/dist/call-diagnostic-events-batcher.js.map +0 -1
- package/src/call-diagnostic-events-batcher.js +0 -62
- package/src/index.js +0 -17
- package/test/unit/spec/call-diagnostic-events-batcher.js +0 -195
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {assert} from '@webex/test-helper-chai';
|
|
6
|
-
import FakeTimers from '@sinonjs/fake-timers';
|
|
7
|
-
import Metrics, {config} from '@webex/internal-plugin-metrics';
|
|
8
|
-
import MockWebex from '@webex/test-helper-mock-webex';
|
|
9
|
-
import sinon from 'sinon';
|
|
10
|
-
import {WebexHttpError} from '@webex/webex-core';
|
|
11
|
-
|
|
12
|
-
function promiseTick(count) {
|
|
13
|
-
let promise = Promise.resolve();
|
|
14
|
-
|
|
15
|
-
while (count > 1) {
|
|
16
|
-
promise = promise.then(() => promiseTick(1));
|
|
17
|
-
count -= 1;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return promise;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
describe('plugin-metrics', () => {
|
|
24
|
-
describe('callDiagnosticEventsBatcher', () => {
|
|
25
|
-
let webex;
|
|
26
|
-
|
|
27
|
-
beforeEach(() => {
|
|
28
|
-
webex = new MockWebex({
|
|
29
|
-
children: {
|
|
30
|
-
metrics: Metrics,
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
webex.config.metrics = config.metrics;
|
|
35
|
-
|
|
36
|
-
webex.request = function (options) {
|
|
37
|
-
return Promise.resolve({
|
|
38
|
-
statusCode: 204,
|
|
39
|
-
body: undefined,
|
|
40
|
-
options,
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
sinon.spy(webex, 'request');
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
let clock;
|
|
47
|
-
|
|
48
|
-
beforeEach(() => {
|
|
49
|
-
clock = FakeTimers.install();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
afterEach(() => {
|
|
53
|
-
clock.uninstall();
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
describe('#request()', () => {
|
|
57
|
-
describe('when the request completes successfully', () => {
|
|
58
|
-
it('clears the queue', () => {
|
|
59
|
-
clock.uninstall();
|
|
60
|
-
|
|
61
|
-
return webex.internal.metrics.callDiagnosticEventsBatcher
|
|
62
|
-
.request({
|
|
63
|
-
type: 'diagnostic-event',
|
|
64
|
-
eventPayload: {
|
|
65
|
-
originTime: {
|
|
66
|
-
triggered: 'mock triggered timestamp',
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
})
|
|
70
|
-
.then(() => {
|
|
71
|
-
assert.calledOnce(webex.request);
|
|
72
|
-
assert.lengthOf(webex.internal.metrics.callDiagnosticEventsBatcher.queue, 0);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
describe('when the request fails due to network disconnect', () => {
|
|
78
|
-
it('reenqueues the payload', () => {
|
|
79
|
-
// sinon appears to have gap in its api where stub.onCall(n) doesn't
|
|
80
|
-
// accept a function, so the following is more verbose than one might
|
|
81
|
-
// desire
|
|
82
|
-
webex.request = function () {
|
|
83
|
-
// noop
|
|
84
|
-
};
|
|
85
|
-
let count = 0;
|
|
86
|
-
|
|
87
|
-
sinon.stub(webex, 'request').callsFake((options) => {
|
|
88
|
-
options.headers = {
|
|
89
|
-
trackingid: count,
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
count += 1;
|
|
93
|
-
if (count < 9) {
|
|
94
|
-
return Promise.reject(
|
|
95
|
-
new WebexHttpError.NetworkOrCORSError({
|
|
96
|
-
statusCode: 0,
|
|
97
|
-
options,
|
|
98
|
-
})
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return Promise.resolve({
|
|
103
|
-
statusCode: 204,
|
|
104
|
-
body: undefined,
|
|
105
|
-
options,
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
const promise = webex.internal.metrics.callDiagnosticEventsBatcher.request({
|
|
110
|
-
type: 'diagnostic-event',
|
|
111
|
-
eventPayload: {
|
|
112
|
-
originTime: {
|
|
113
|
-
triggered: 'mock triggered timestamp',
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
return promiseTick(50)
|
|
119
|
-
.then(() =>
|
|
120
|
-
assert.lengthOf(webex.internal.metrics.callDiagnosticEventsBatcher.queue, 1)
|
|
121
|
-
)
|
|
122
|
-
.then(() => clock.tick(config.metrics.batcherWait))
|
|
123
|
-
.then(() => assert.calledOnce(webex.request))
|
|
124
|
-
|
|
125
|
-
.then(() => promiseTick(50))
|
|
126
|
-
.then(() => clock.tick(1000))
|
|
127
|
-
.then(() => promiseTick(50))
|
|
128
|
-
.then(() => clock.tick(config.metrics.batcherWait))
|
|
129
|
-
.then(() => assert.calledTwice(webex.request))
|
|
130
|
-
|
|
131
|
-
.then(() => promiseTick(50))
|
|
132
|
-
.then(() => clock.tick(2000))
|
|
133
|
-
.then(() => promiseTick(50))
|
|
134
|
-
.then(() => clock.tick(config.metrics.batcherWait))
|
|
135
|
-
.then(() => assert.calledThrice(webex.request))
|
|
136
|
-
|
|
137
|
-
.then(() => promiseTick(50))
|
|
138
|
-
.then(() => clock.tick(4000))
|
|
139
|
-
.then(() => promiseTick(50))
|
|
140
|
-
.then(() => clock.tick(config.metrics.batcherWait))
|
|
141
|
-
.then(() => assert.callCount(webex.request, 4))
|
|
142
|
-
|
|
143
|
-
.then(() => promiseTick(50))
|
|
144
|
-
.then(() => clock.tick(8000))
|
|
145
|
-
.then(() => promiseTick(50))
|
|
146
|
-
.then(() => clock.tick(config.metrics.batcherWait))
|
|
147
|
-
.then(() => assert.callCount(webex.request, 5))
|
|
148
|
-
|
|
149
|
-
.then(() => promiseTick(50))
|
|
150
|
-
.then(() => clock.tick(16000))
|
|
151
|
-
.then(() => promiseTick(50))
|
|
152
|
-
.then(() => clock.tick(config.metrics.batcherWait))
|
|
153
|
-
.then(() => assert.callCount(webex.request, 6))
|
|
154
|
-
|
|
155
|
-
.then(() => promiseTick(50))
|
|
156
|
-
.then(() => clock.tick(32000))
|
|
157
|
-
.then(() => promiseTick(50))
|
|
158
|
-
.then(() => clock.tick(config.metrics.batcherWait))
|
|
159
|
-
.then(() => assert.callCount(webex.request, 7))
|
|
160
|
-
|
|
161
|
-
.then(() => promiseTick(50))
|
|
162
|
-
.then(() => clock.tick(32000))
|
|
163
|
-
.then(() => promiseTick(50))
|
|
164
|
-
.then(() => clock.tick(config.metrics.batcherWait))
|
|
165
|
-
.then(() => assert.callCount(webex.request, 8))
|
|
166
|
-
|
|
167
|
-
.then(() => promiseTick(50))
|
|
168
|
-
.then(() => clock.tick(32000))
|
|
169
|
-
.then(() => promiseTick(50))
|
|
170
|
-
.then(() => clock.tick(config.metrics.batcherWait))
|
|
171
|
-
.then(() => assert.callCount(webex.request, 9))
|
|
172
|
-
|
|
173
|
-
.then(() => promiseTick(50))
|
|
174
|
-
.then(() =>
|
|
175
|
-
assert.lengthOf(webex.internal.metrics.callDiagnosticEventsBatcher.queue, 0)
|
|
176
|
-
)
|
|
177
|
-
.then(() => promise)
|
|
178
|
-
.then(() => {
|
|
179
|
-
assert.lengthOf(
|
|
180
|
-
webex.request.args[1][0].body.metrics,
|
|
181
|
-
1,
|
|
182
|
-
'Reenqueuing the metric once did not increase the number of metrics to be submitted'
|
|
183
|
-
);
|
|
184
|
-
assert.lengthOf(
|
|
185
|
-
webex.request.args[2][0].body.metrics,
|
|
186
|
-
1,
|
|
187
|
-
'Reenqueuing the metric twice did not increase the number of metrics to be submitted'
|
|
188
|
-
);
|
|
189
|
-
assert.lengthOf(webex.internal.metrics.callDiagnosticEventsBatcher.queue, 0);
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
});
|