@webex/internal-plugin-metrics 3.12.0-auth-prejoin-fetch.1 → 3.12.0-llmrefactor.10
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/README.md +239 -1
- package/dist/call-diagnostic/call-diagnostic-metrics.js +52 -18
- package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -1
- package/dist/call-diagnostic/config.js +3 -1
- package/dist/call-diagnostic/config.js.map +1 -1
- package/dist/config.js +4 -0
- package/dist/config.js.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/metrics.js +118 -5
- package/dist/metrics.js.map +1 -1
- package/dist/network-telemetry.js +610 -0
- package/dist/network-telemetry.js.map +1 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +9 -3
- package/dist/types/call-diagnostic/config.d.ts +2 -0
- package/dist/types/config.d.ts +5 -0
- package/dist/types/network-telemetry.d.ts +108 -0
- package/package.json +10 -10
- package/src/call-diagnostic/call-diagnostic-metrics.ts +56 -20
- package/src/call-diagnostic/config.ts +2 -0
- package/src/config.js +4 -0
- package/src/index.ts +9 -0
- package/src/metrics.js +123 -5
- package/src/network-telemetry.ts +757 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +211 -21
- package/test/unit/spec/metrics.js +14 -5
- package/test/unit/spec/network-telemetry.ts +610 -0
package/src/metrics.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* eslint-disable default-param-last */
|
|
2
|
+
/* eslint-disable valid-jsdoc */
|
|
2
3
|
|
|
3
4
|
/*!
|
|
4
5
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
@@ -11,6 +12,7 @@ import {OS_NAME, OSMap, CLIENT_NAME} from './config';
|
|
|
11
12
|
import Batcher from './batcher';
|
|
12
13
|
import ClientMetricsBatcher from './client-metrics-batcher';
|
|
13
14
|
import ClientMetricsPreloginBatcher from './client-metrics-prelogin-batcher';
|
|
15
|
+
import {createNetworkTelemetryCollector} from './network-telemetry';
|
|
14
16
|
|
|
15
17
|
const {getOSName, getOSVersion, getBrowserName, getBrowserVersion} = BrowserDetection();
|
|
16
18
|
|
|
@@ -43,6 +45,119 @@ const Metrics = WebexPlugin.extend({
|
|
|
43
45
|
|
|
44
46
|
namespace: 'Metrics',
|
|
45
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Registers SDK request outcome monitoring.
|
|
50
|
+
* @param args
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
initialize(...args) {
|
|
54
|
+
WebexPlugin.prototype.initialize.call(this, ...args);
|
|
55
|
+
|
|
56
|
+
// Metrics may also be constructed as a standalone plugin. Request events are
|
|
57
|
+
// available only when it is attached to a Webex instance.
|
|
58
|
+
if (!this.parent && !this.collection) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const initializeNetworkTelemetry = () => {
|
|
63
|
+
if (
|
|
64
|
+
this.networkTelemetry ||
|
|
65
|
+
this.webex?.config?.metrics?.networkTelemetry?.enabled !== true
|
|
66
|
+
) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
this.networkTelemetry = createNetworkTelemetryCollector({
|
|
71
|
+
intervalMs: this.webex.config.metrics.networkTelemetry.intervalMs,
|
|
72
|
+
submitMetric: this.submitNetworkTelemetryMetric.bind(this),
|
|
73
|
+
onSubmissionFailure: this.handleNetworkTelemetrySubmissionFailure.bind(this),
|
|
74
|
+
});
|
|
75
|
+
this.listenTo(this.webex, 'request:start', this.recordNetworkRequestStart);
|
|
76
|
+
this.listenTo(this.webex, 'request:success', this.recordNetworkRequestSuccess);
|
|
77
|
+
this.listenTo(this.webex, 'request:failure', this.recordNetworkRequestFailure);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// Ampersand initializes children before WebexCore.initialize() populates
|
|
81
|
+
// webex.config. Run immediately for already-configured hosts (including
|
|
82
|
+
// MockWebex), and listen for the real core's post-initialization notification.
|
|
83
|
+
this.listenToOnce(this.webex, 'change:config', initializeNetworkTelemetry);
|
|
84
|
+
initializeNetworkTelemetry();
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Records an SDK request being sent in the current reporting window.
|
|
89
|
+
* @param options
|
|
90
|
+
* @returns
|
|
91
|
+
*/
|
|
92
|
+
recordNetworkRequestStart(options) {
|
|
93
|
+
this.networkTelemetry.recordRequest(options);
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Records a successful SDK request for the current reporting window.
|
|
98
|
+
* @param options
|
|
99
|
+
* @returns
|
|
100
|
+
*/
|
|
101
|
+
recordNetworkRequestSuccess(options) {
|
|
102
|
+
this.networkTelemetry.recordResponse(options);
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Records a failed SDK request for the current reporting window.
|
|
107
|
+
* @param options
|
|
108
|
+
* @param reason
|
|
109
|
+
* @returns
|
|
110
|
+
*/
|
|
111
|
+
recordNetworkRequestFailure(options, reason) {
|
|
112
|
+
this.networkTelemetry.recordFailure(options, reason);
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Submits the current network telemetry window immediately.
|
|
117
|
+
* @returns
|
|
118
|
+
*/
|
|
119
|
+
flushNetworkTelemetry() {
|
|
120
|
+
if (!this.networkTelemetry) {
|
|
121
|
+
return Promise.resolve();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return this.networkTelemetry.flush();
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Submits a completed network telemetry window through client metrics.
|
|
129
|
+
* @param name
|
|
130
|
+
* @param properties
|
|
131
|
+
* @returns
|
|
132
|
+
*/
|
|
133
|
+
submitNetworkTelemetryMetric(name, properties) {
|
|
134
|
+
return this.submitClientMetrics(name, properties);
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Logs a network telemetry submission failure without affecting SDK requests.
|
|
139
|
+
* @returns
|
|
140
|
+
*/
|
|
141
|
+
handleNetworkTelemetrySubmissionFailure() {
|
|
142
|
+
this.webex.logger?.warn('metrics: failed to submit network request summary telemetry');
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Stops network telemetry collection and submission.
|
|
147
|
+
* @returns
|
|
148
|
+
*/
|
|
149
|
+
stopNetworkTelemetry() {
|
|
150
|
+
if (!this.networkTelemetry) {
|
|
151
|
+
return Promise.resolve();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
this.stopListening(this.webex, 'request:start', this.recordNetworkRequestStart);
|
|
155
|
+
this.stopListening(this.webex, 'request:success', this.recordNetworkRequestSuccess);
|
|
156
|
+
this.stopListening(this.webex, 'request:failure', this.recordNetworkRequestFailure);
|
|
157
|
+
|
|
158
|
+
return this.networkTelemetry.stop();
|
|
159
|
+
},
|
|
160
|
+
|
|
46
161
|
submit(key, value) {
|
|
47
162
|
return this.batcher.request({key, ...value});
|
|
48
163
|
},
|
|
@@ -60,17 +175,20 @@ const Metrics = WebexPlugin.extend({
|
|
|
60
175
|
const payload = {metricName: eventName};
|
|
61
176
|
// @ts-ignore
|
|
62
177
|
const providedClientVersion = this.webex.meetings?.config?.metrics?.clientVersion;
|
|
178
|
+
const {appName, appVersion} = this.webex.config;
|
|
179
|
+
// Browser location is unavailable when the SDK runs in Node.js.
|
|
180
|
+
// eslint-disable-next-line no-undef
|
|
181
|
+
const browserLocation = typeof window !== 'undefined' ? window.location : undefined;
|
|
63
182
|
|
|
64
183
|
payload.tags = {
|
|
65
184
|
...props.tags,
|
|
185
|
+
app_name: appName ?? 'unknown',
|
|
186
|
+
app_url: browserLocation?.origin || browserLocation?.hostname || 'non-browser',
|
|
187
|
+
app_version: appVersion ?? 'unknown',
|
|
66
188
|
browser: getBrowserName(),
|
|
67
189
|
os: getOSNameInternal(),
|
|
68
190
|
appVersion: providedClientVersion,
|
|
69
|
-
|
|
70
|
-
// Node does not like this so we need to check if it exists or not
|
|
71
|
-
// eslint-disable-next-line no-undef
|
|
72
|
-
domain:
|
|
73
|
-
typeof window !== 'undefined' ? window.location.hostname || 'non-browser' : 'non-browser', // Check what else we could measure
|
|
191
|
+
domain: browserLocation?.hostname || 'non-browser',
|
|
74
192
|
};
|
|
75
193
|
|
|
76
194
|
payload.fields = {
|