@webex/internal-plugin-metrics 3.0.0-beta.35 → 3.0.0-beta.351

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.
Files changed (68) hide show
  1. package/dist/batcher.js +2 -1
  2. package/dist/batcher.js.map +1 -1
  3. package/dist/call-diagnostic/call-diagnostic-metrics-batcher.js +65 -0
  4. package/dist/call-diagnostic/call-diagnostic-metrics-batcher.js.map +1 -0
  5. package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js +456 -0
  6. package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js.map +1 -0
  7. package/dist/call-diagnostic/call-diagnostic-metrics.js +827 -0
  8. package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -0
  9. package/dist/call-diagnostic/call-diagnostic-metrics.util.js +337 -0
  10. package/dist/call-diagnostic/call-diagnostic-metrics.util.js.map +1 -0
  11. package/dist/call-diagnostic/config.js +610 -0
  12. package/dist/call-diagnostic/config.js.map +1 -0
  13. package/dist/client-metrics-batcher.js +2 -1
  14. package/dist/client-metrics-batcher.js.map +1 -1
  15. package/dist/config.js +2 -1
  16. package/dist/config.js.map +1 -1
  17. package/dist/index.js +18 -0
  18. package/dist/index.js.map +1 -1
  19. package/dist/metrics.js +23 -28
  20. package/dist/metrics.js.map +1 -1
  21. package/dist/metrics.types.js +7 -0
  22. package/dist/metrics.types.js.map +1 -0
  23. package/dist/new-metrics.js +333 -0
  24. package/dist/new-metrics.js.map +1 -0
  25. package/dist/types/batcher.d.ts +2 -0
  26. package/dist/types/call-diagnostic/call-diagnostic-metrics-batcher.d.ts +2 -0
  27. package/dist/types/call-diagnostic/call-diagnostic-metrics-latencies.d.ts +194 -0
  28. package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +418 -0
  29. package/dist/types/call-diagnostic/call-diagnostic-metrics.util.d.ts +96 -0
  30. package/dist/types/call-diagnostic/config.d.ts +172 -0
  31. package/dist/types/client-metrics-batcher.d.ts +2 -0
  32. package/dist/types/config.d.ts +36 -0
  33. package/dist/types/index.d.ts +13 -0
  34. package/dist/types/metrics.d.ts +3 -0
  35. package/dist/types/metrics.types.d.ts +104 -0
  36. package/dist/types/new-metrics.d.ts +139 -0
  37. package/dist/types/utils.d.ts +6 -0
  38. package/dist/utils.js +27 -0
  39. package/dist/utils.js.map +1 -0
  40. package/package.json +13 -8
  41. package/src/batcher.js +1 -0
  42. package/src/call-diagnostic/call-diagnostic-metrics-batcher.ts +75 -0
  43. package/src/call-diagnostic/call-diagnostic-metrics-latencies.ts +419 -0
  44. package/src/call-diagnostic/call-diagnostic-metrics.ts +882 -0
  45. package/src/call-diagnostic/call-diagnostic-metrics.util.ts +362 -0
  46. package/src/call-diagnostic/config.ts +666 -0
  47. package/src/client-metrics-batcher.js +1 -0
  48. package/src/config.js +1 -0
  49. package/src/index.ts +43 -0
  50. package/src/metrics.js +18 -24
  51. package/src/metrics.types.ts +160 -0
  52. package/src/new-metrics.ts +317 -0
  53. package/src/utils.ts +17 -0
  54. package/test/unit/spec/batcher.js +2 -0
  55. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +452 -0
  56. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-latencies.ts +506 -0
  57. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +2109 -0
  58. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +565 -0
  59. package/test/unit/spec/client-metrics-batcher.js +2 -0
  60. package/test/unit/spec/metrics.js +66 -97
  61. package/test/unit/spec/new-metrics.ts +267 -0
  62. package/test/unit/spec/utils.ts +22 -0
  63. package/tsconfig.json +6 -0
  64. package/dist/call-diagnostic-events-batcher.js +0 -60
  65. package/dist/call-diagnostic-events-batcher.js.map +0 -1
  66. package/src/call-diagnostic-events-batcher.js +0 -62
  67. package/src/index.js +0 -17
  68. 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
- });