@nsshunt/stsobservability 1.0.111 → 1.0.113
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/stsobservability.mjs +1240 -1416
- package/dist/stsobservability.mjs.map +1 -1
- package/dist/stsobservability.umd.js +1243 -1419
- package/dist/stsobservability.umd.js.map +1 -1
- package/package.json +9 -10
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __typeError = (msg) => {
|
|
3
|
-
throw TypeError(msg);
|
|
4
|
-
};
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
8
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
|
-
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
12
|
-
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
13
|
-
set _(value) {
|
|
14
|
-
__privateSet(obj, member, value, setter);
|
|
15
|
-
},
|
|
16
|
-
get _() {
|
|
17
|
-
return __privateGet(obj, member, getter);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
var _a, _label, _options, _data, _val, _interval, _timeoutComputeVelocity, _lastVelocity, _delta, _maxVelocity, _timerInterval, _copy, _velocity, _velocityVal, _valStack, _averageValStack, _maxAverageValStack, _maxAverageIterations, _valStackMaxLength, _valStackAverage, _timeStamp, _maxTimeDiff, _vaTimeDiff, _velocityTimeDiff, _autoComputeVelocity, _autoComputeVelocityTimeout, _countDiff, _timeDiff, _deltaCountDiff, _deltaTimeDif, _minTimeForReporting, _averageVelocity, _InstrumentVelocity_instances, ComputeVelocityByTimeDiff_fn, ComputeVelocity_fn, SetupAutoComputeVelocity_fn, GetVelocityStackAverage_fn, GetVal_fn, SetVal_fn, GetVelocity_fn, GetMaxVelocity_fn, GetDelta_fn, GetTimeStamp_fn, GetCountDiff_fn, GetTimeDiff_fn, GetDeltaCountDiff_fn, GetDeltaTimeDif_fn, GetAverageVelocity_fn, _histogramData, _val2, _copy2, _InstrumentHistogram_instances, GetVal_fn2, SetVal_fn2, GetHistogramData_fn, SetHistogramData_fn, _messages, _readPos, _maxSize, _copy3, _useLatestMessages, _consoleLogging, _instrumentLogging, _winstonLogging, _stsLogger, _InstrumentLog_instances, DumpToConsole_fn, GetVal_fn3, SetVal_fn3, _start, _copy4, _pauseVal, _InstrumentTimerGauge_instances, GetVal_fn4, SetVal_fn4, _val3, _maxval, _lastObservedValue, _timeSeriesList, _maxSampleSize, _timerInterval2, _observer, _min, _max, _observations, _total, _copy5, _InstrumentGauge_instances, GetVal_fn5, SetVal_fn5, GetMin_fn, GetMax_fn, GetAverage_fn, GetAndResetMaxVal_fn, NumberCompare_fn, GetPercentileData_fn, _val4, _copy6, _InstrumentObject_instances, GetVal_fn6, SetVal_fn6, _tinyEmitter, _RequestCompleted, _inPublish, _observer2, _publishState, _publisherTransport, _PublishInstruments_instances, PublishTimeoutLoop_fn, UpdateState_fn, _instruments, _publisher, _PublishInstrumentController_instances, GetInstrument_fn, ProcessTelemetryCommand_fn, CreateInstrument_fn, CreateInstruments_fn, _kafkaLog, _maxLogLength, _socketSubscribeKeepAlive, _options2, _ObservabilityRESTAPISubscriber_instances, LogDebugMessage_fn, LogErrorMessage_fn, InvokeRESTAPI_fn, _GetData, SetupTimeout_fn, AddKeepAlive_fn, RemoveKeepAlive_fn, _messageWithAckPayloadRecords, _socket, _maxReties, _timeoutValue, _options3, _SocketIoMessageSender_instances, LogDebugMessage_fn2, GetSubscribeKeepAliveAckEventName_fn, _socketSubscribeKeepAlive2, _socket2, _options4, _socketIoMessageSender, _ObservabilitySocketIOSubscriber_instances, LogDebugMessage_fn3, LogErrorMessage_fn2, AddKeepAlive_fn2, RemoveKeepAlive_fn2, _observabilitySocketIOSubscriber, _subscriptions, _kafkaHelper, _serviceModel, _agentModel, _lambdaModel, _options5, _ObservabilitySubscriptionManager_instances, LogDebugMessage_fn4, LogErrorMessage_fn3;
|
|
21
1
|
import _cloneDeep from "lodash.clonedeep";
|
|
22
2
|
import isNode from "detect-node";
|
|
23
3
|
import { STSOptionsBase, STSAxiosConfig } from "@nsshunt/stsutils";
|
|
@@ -66,35 +46,32 @@ var GaugeTypes = /* @__PURE__ */ ((GaugeTypes2) => {
|
|
|
66
46
|
return GaugeTypes2;
|
|
67
47
|
})(GaugeTypes || {});
|
|
68
48
|
class InstrumentBaseOptions {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
__publicField(this, "label");
|
|
73
|
-
}
|
|
49
|
+
fixedSize;
|
|
50
|
+
padLength;
|
|
51
|
+
label;
|
|
74
52
|
}
|
|
75
53
|
class InstrumentBaseTelemetry {
|
|
76
54
|
}
|
|
77
|
-
_a = GaugeTypes.GAUGE_TYPE;
|
|
78
55
|
class InstrumentBase {
|
|
56
|
+
#label = "";
|
|
57
|
+
#options = null;
|
|
58
|
+
#data = {};
|
|
79
59
|
// Use for copy objects only.
|
|
80
60
|
//protected _data: Record<string, any> = { };
|
|
81
61
|
constructor(options = {}) {
|
|
82
|
-
__privateAdd(this, _label, "");
|
|
83
|
-
__privateAdd(this, _options, null);
|
|
84
|
-
__privateAdd(this, _data, {});
|
|
85
|
-
__publicField(this, _a, GaugeTypes.INSTRUMENT_OBJECT);
|
|
86
|
-
// Default Gauge type
|
|
87
|
-
__publicField(this, "val");
|
|
88
62
|
if (typeof options === "string" || options instanceof String) {
|
|
89
63
|
throw new Error("Instrument parameter must be an options object.");
|
|
90
64
|
}
|
|
91
|
-
|
|
65
|
+
this.#options = options;
|
|
92
66
|
if (options.label) {
|
|
93
|
-
|
|
67
|
+
this.#label = options.label;
|
|
94
68
|
} else {
|
|
95
|
-
|
|
69
|
+
this.#label = "InstrumentGauge";
|
|
96
70
|
}
|
|
97
71
|
}
|
|
72
|
+
[GaugeTypes.GAUGE_TYPE] = GaugeTypes.INSTRUMENT_OBJECT;
|
|
73
|
+
// Default Gauge type
|
|
74
|
+
val;
|
|
98
75
|
WithLabel(label) {
|
|
99
76
|
this.label = label;
|
|
100
77
|
return this;
|
|
@@ -103,12 +80,12 @@ class InstrumentBase {
|
|
|
103
80
|
propertyNames.forEach((propertyName) => {
|
|
104
81
|
Object.defineProperty(this, propertyName, {
|
|
105
82
|
enumerable: true,
|
|
106
|
-
get: () =>
|
|
83
|
+
get: () => this.#data[propertyName],
|
|
107
84
|
set: (value) => {
|
|
108
85
|
if (value === void 0) {
|
|
109
86
|
return;
|
|
110
87
|
}
|
|
111
|
-
|
|
88
|
+
this.#data[propertyName] = value;
|
|
112
89
|
}
|
|
113
90
|
});
|
|
114
91
|
});
|
|
@@ -121,16 +98,16 @@ class InstrumentBase {
|
|
|
121
98
|
}
|
|
122
99
|
}
|
|
123
100
|
get options() {
|
|
124
|
-
return
|
|
101
|
+
return this.#options;
|
|
125
102
|
}
|
|
126
103
|
set options(optionsValue) {
|
|
127
|
-
|
|
104
|
+
this.#options = optionsValue;
|
|
128
105
|
}
|
|
129
106
|
get label() {
|
|
130
|
-
return
|
|
107
|
+
return this.#label;
|
|
131
108
|
}
|
|
132
109
|
set label(labelValue) {
|
|
133
|
-
|
|
110
|
+
this.#label = labelValue;
|
|
134
111
|
}
|
|
135
112
|
StopTimer() {
|
|
136
113
|
}
|
|
@@ -163,137 +140,116 @@ class InstrumentBase {
|
|
|
163
140
|
}
|
|
164
141
|
*/
|
|
165
142
|
}
|
|
166
|
-
_label = new WeakMap();
|
|
167
|
-
_options = new WeakMap();
|
|
168
|
-
_data = new WeakMap();
|
|
169
143
|
class InstrumentVelocityOptions extends InstrumentBaseOptions {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
__publicField(this, "vaTimeDiff");
|
|
181
|
-
__publicField(this, "autoComputeVelocityTimeout");
|
|
182
|
-
}
|
|
144
|
+
interval;
|
|
145
|
+
valStackMaxLength;
|
|
146
|
+
maxAverageValStack;
|
|
147
|
+
maxAverageIterations;
|
|
148
|
+
fromJSON;
|
|
149
|
+
initValue;
|
|
150
|
+
autoComputeVelocity;
|
|
151
|
+
velocityTimeDiff;
|
|
152
|
+
vaTimeDiff;
|
|
153
|
+
autoComputeVelocityTimeout;
|
|
183
154
|
}
|
|
184
155
|
class InstrumentVelocityTelemetry extends InstrumentBaseTelemetry {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
__publicField(this, "val");
|
|
188
|
-
__publicField(this, "Inc");
|
|
189
|
-
}
|
|
156
|
+
val;
|
|
157
|
+
Inc;
|
|
190
158
|
}
|
|
191
159
|
class InstrumentVelocity extends InstrumentBase {
|
|
160
|
+
// eslint-disable-next-line @/no-unused-private-class-members
|
|
161
|
+
#val = 0;
|
|
162
|
+
#interval = null;
|
|
163
|
+
#timeoutComputeVelocity = null;
|
|
164
|
+
// eslint-disable-next-line @/no-unused-private-class-members
|
|
165
|
+
#lastVelocity = 0;
|
|
166
|
+
#delta = 0;
|
|
167
|
+
#maxVelocity = 0;
|
|
168
|
+
#timerInterval = 0;
|
|
169
|
+
#copy = false;
|
|
170
|
+
#velocity = 0;
|
|
171
|
+
#velocityVal = 0;
|
|
172
|
+
#valStack = [];
|
|
173
|
+
#averageValStack = [];
|
|
174
|
+
#maxAverageValStack = 0;
|
|
175
|
+
#maxAverageIterations = 0;
|
|
176
|
+
// eslint-disable-next-line @/no-unused-private-class-members
|
|
177
|
+
#valStackMaxLength = 0;
|
|
178
|
+
#valStackAverage = 0;
|
|
179
|
+
#timeStamp = 0;
|
|
180
|
+
#maxTimeDiff = 0;
|
|
181
|
+
#vaTimeDiff = 0;
|
|
182
|
+
#velocityTimeDiff = 0;
|
|
183
|
+
#autoComputeVelocity = false;
|
|
184
|
+
#autoComputeVelocityTimeout = 0;
|
|
185
|
+
// 50ms to auto computer after an update when not in auto compute mode.
|
|
186
|
+
#countDiff = 0;
|
|
187
|
+
#timeDiff = 0;
|
|
188
|
+
#deltaCountDiff = 0;
|
|
189
|
+
#deltaTimeDif = 0;
|
|
190
|
+
#minTimeForReporting = 0;
|
|
191
|
+
#averageVelocity = [];
|
|
192
192
|
// timeWindow = Number of intervals to use as the sliding time window same size. Uses average value within the time window. Larger window produces a smooth (more laggy) curve. Shorter time
|
|
193
193
|
// window may be "spikey" depending on the volatility of the data being recorded.
|
|
194
194
|
constructor(options = {}) {
|
|
195
195
|
super(options);
|
|
196
|
-
__privateAdd(this, _InstrumentVelocity_instances);
|
|
197
|
-
// eslint-disable-next-line @/no-unused-private-class-members
|
|
198
|
-
__privateAdd(this, _val, 0);
|
|
199
|
-
__privateAdd(this, _interval, null);
|
|
200
|
-
__privateAdd(this, _timeoutComputeVelocity, null);
|
|
201
|
-
// eslint-disable-next-line @/no-unused-private-class-members
|
|
202
|
-
__privateAdd(this, _lastVelocity, 0);
|
|
203
|
-
__privateAdd(this, _delta, 0);
|
|
204
|
-
__privateAdd(this, _maxVelocity, 0);
|
|
205
|
-
__privateAdd(this, _timerInterval, 0);
|
|
206
|
-
__privateAdd(this, _copy, false);
|
|
207
|
-
__privateAdd(this, _velocity, 0);
|
|
208
|
-
__privateAdd(this, _velocityVal, 0);
|
|
209
|
-
__privateAdd(this, _valStack, []);
|
|
210
|
-
__privateAdd(this, _averageValStack, []);
|
|
211
|
-
__privateAdd(this, _maxAverageValStack, 0);
|
|
212
|
-
__privateAdd(this, _maxAverageIterations, 0);
|
|
213
|
-
// eslint-disable-next-line @/no-unused-private-class-members
|
|
214
|
-
__privateAdd(this, _valStackMaxLength, 0);
|
|
215
|
-
__privateAdd(this, _valStackAverage, 0);
|
|
216
|
-
__privateAdd(this, _timeStamp, 0);
|
|
217
|
-
__privateAdd(this, _maxTimeDiff, 0);
|
|
218
|
-
__privateAdd(this, _vaTimeDiff, 0);
|
|
219
|
-
__privateAdd(this, _velocityTimeDiff, 0);
|
|
220
|
-
__privateAdd(this, _autoComputeVelocity, false);
|
|
221
|
-
__privateAdd(this, _autoComputeVelocityTimeout, 0);
|
|
222
|
-
// 50ms to auto computer after an update when not in auto compute mode.
|
|
223
|
-
__privateAdd(this, _countDiff, 0);
|
|
224
|
-
__privateAdd(this, _timeDiff, 0);
|
|
225
|
-
__privateAdd(this, _deltaCountDiff, 0);
|
|
226
|
-
__privateAdd(this, _deltaTimeDif, 0);
|
|
227
|
-
__privateAdd(this, _minTimeForReporting, 0);
|
|
228
|
-
__privateAdd(this, _averageVelocity, []);
|
|
229
|
-
__publicField(this, "maxVelocity", 0);
|
|
230
|
-
__publicField(this, "delta", 0);
|
|
231
|
-
__publicField(this, "velocity", 0);
|
|
232
|
-
__publicField(this, "va", 0);
|
|
233
|
-
__publicField(this, "timeStamp", 0);
|
|
234
|
-
__publicField(this, "countDiff", 0);
|
|
235
|
-
__publicField(this, "timeDiff", 0);
|
|
236
|
-
__publicField(this, "deltaCountDiff", 0);
|
|
237
|
-
__publicField(this, "deltaTimeDif", 0);
|
|
238
|
-
__publicField(this, "averageVelocity", []);
|
|
239
|
-
__publicField(this, "val", 0);
|
|
240
196
|
if (typeof options.label === "undefined") {
|
|
241
197
|
this.label = "InstrumentVelocity";
|
|
242
198
|
} else {
|
|
243
199
|
this.label = options.label;
|
|
244
200
|
}
|
|
245
201
|
if (typeof options.interval === "undefined") {
|
|
246
|
-
|
|
202
|
+
this.#timerInterval = 1e3;
|
|
247
203
|
} else {
|
|
248
|
-
|
|
204
|
+
this.#timerInterval = options.interval;
|
|
249
205
|
}
|
|
250
206
|
if (typeof options.valStackMaxLength === "undefined") {
|
|
251
|
-
|
|
207
|
+
this.#valStackMaxLength = 100;
|
|
252
208
|
} else {
|
|
253
|
-
|
|
209
|
+
this.#valStackMaxLength = options.valStackMaxLength;
|
|
254
210
|
}
|
|
255
211
|
if (typeof options.fromJSON === "undefined") {
|
|
256
|
-
|
|
212
|
+
this.#copy = false;
|
|
257
213
|
} else {
|
|
258
|
-
|
|
214
|
+
this.#copy = true;
|
|
259
215
|
}
|
|
260
216
|
if (typeof options.autoComputeVelocity === "undefined") {
|
|
261
|
-
|
|
217
|
+
this.#autoComputeVelocity = false;
|
|
262
218
|
} else {
|
|
263
|
-
|
|
219
|
+
this.#autoComputeVelocity = options.autoComputeVelocity;
|
|
264
220
|
}
|
|
265
221
|
if (typeof options.maxAverageValStack === "undefined") {
|
|
266
|
-
|
|
222
|
+
this.#maxAverageValStack = 5;
|
|
267
223
|
} else {
|
|
268
|
-
|
|
224
|
+
this.#maxAverageValStack = options.maxAverageValStack;
|
|
269
225
|
}
|
|
270
226
|
if (typeof options.maxAverageIterations === "undefined") {
|
|
271
|
-
|
|
227
|
+
this.#maxAverageIterations = 3;
|
|
272
228
|
} else {
|
|
273
|
-
|
|
229
|
+
this.#maxAverageIterations = options.maxAverageIterations;
|
|
274
230
|
}
|
|
275
231
|
if (typeof options.velocityTimeDiff === "undefined") {
|
|
276
|
-
|
|
232
|
+
this.#velocityTimeDiff = 5e3;
|
|
277
233
|
} else {
|
|
278
|
-
|
|
234
|
+
this.#velocityTimeDiff = options.velocityTimeDiff;
|
|
279
235
|
}
|
|
280
236
|
if (typeof options.vaTimeDiff === "undefined") {
|
|
281
|
-
|
|
237
|
+
this.#vaTimeDiff = 1e4;
|
|
282
238
|
} else {
|
|
283
|
-
|
|
239
|
+
this.#vaTimeDiff = options.vaTimeDiff;
|
|
284
240
|
}
|
|
285
241
|
if (typeof options.autoComputeVelocityTimeout === "undefined") {
|
|
286
|
-
|
|
242
|
+
this.#autoComputeVelocityTimeout = 50;
|
|
287
243
|
} else {
|
|
288
|
-
|
|
244
|
+
this.#autoComputeVelocityTimeout = options.autoComputeVelocityTimeout;
|
|
289
245
|
}
|
|
290
|
-
|
|
291
|
-
|
|
246
|
+
this.#maxTimeDiff = this.#vaTimeDiff * 2;
|
|
247
|
+
this.#minTimeForReporting = this.#vaTimeDiff + 2e3;
|
|
292
248
|
Object.defineProperty(this, GaugeTypes.GAUGE_TYPE, {
|
|
293
249
|
enumerable: true,
|
|
294
250
|
get: () => GaugeTypes.INSTRUMENT_VELOCITY
|
|
295
251
|
});
|
|
296
|
-
if (
|
|
252
|
+
if (this.#copy) {
|
|
297
253
|
this.DefineCopyProperties([
|
|
298
254
|
"val",
|
|
299
255
|
"maxVelocity",
|
|
@@ -310,52 +266,52 @@ class InstrumentVelocity extends InstrumentBase {
|
|
|
310
266
|
} else {
|
|
311
267
|
Object.defineProperty(this, "val", {
|
|
312
268
|
enumerable: true,
|
|
313
|
-
get: () =>
|
|
269
|
+
get: () => this.#GetVal(),
|
|
314
270
|
set: (value) => {
|
|
315
|
-
|
|
271
|
+
this.#SetVal(value);
|
|
316
272
|
}
|
|
317
273
|
});
|
|
318
274
|
Object.defineProperty(this, "maxVelocity", {
|
|
319
275
|
enumerable: true,
|
|
320
|
-
get: () =>
|
|
276
|
+
get: () => this.#GetMaxVelocity()
|
|
321
277
|
});
|
|
322
278
|
Object.defineProperty(this, "delta", {
|
|
323
279
|
enumerable: true,
|
|
324
|
-
get: () =>
|
|
280
|
+
get: () => this.#GetDelta()
|
|
325
281
|
});
|
|
326
282
|
Object.defineProperty(this, "velocity", {
|
|
327
283
|
enumerable: true,
|
|
328
|
-
get: () =>
|
|
284
|
+
get: () => this.#GetVelocity()
|
|
329
285
|
});
|
|
330
286
|
Object.defineProperty(this, "va", {
|
|
331
287
|
enumerable: true,
|
|
332
|
-
get: () =>
|
|
288
|
+
get: () => this.#GetVelocityStackAverage()
|
|
333
289
|
});
|
|
334
290
|
Object.defineProperty(this, "timeStamp", {
|
|
335
291
|
enumerable: true,
|
|
336
|
-
get: () =>
|
|
292
|
+
get: () => this.#GetTimeStamp()
|
|
337
293
|
});
|
|
338
294
|
Object.defineProperty(this, "countDiff", {
|
|
339
295
|
enumerable: true,
|
|
340
|
-
get: () =>
|
|
296
|
+
get: () => this.#GetCountDiff()
|
|
341
297
|
});
|
|
342
298
|
Object.defineProperty(this, "timeDiff", {
|
|
343
299
|
enumerable: true,
|
|
344
|
-
get: () =>
|
|
300
|
+
get: () => this.#GetTimeDiff()
|
|
345
301
|
});
|
|
346
302
|
Object.defineProperty(this, "deltaCountDiff", {
|
|
347
303
|
enumerable: true,
|
|
348
|
-
get: () =>
|
|
304
|
+
get: () => this.#GetDeltaCountDiff()
|
|
349
305
|
});
|
|
350
306
|
Object.defineProperty(this, "deltaTimeDif", {
|
|
351
307
|
enumerable: true,
|
|
352
|
-
get: () =>
|
|
308
|
+
get: () => this.#GetDeltaTimeDif()
|
|
353
309
|
});
|
|
354
310
|
Object.defineProperty(this, "averageVelocity", {
|
|
355
311
|
enumerable: true,
|
|
356
|
-
get: () =>
|
|
312
|
+
get: () => this.#GetAverageVelocity()
|
|
357
313
|
});
|
|
358
|
-
if (
|
|
314
|
+
if (this.#timerInterval > 0 && this.#autoComputeVelocity === false) {
|
|
359
315
|
this._StartTimer();
|
|
360
316
|
}
|
|
361
317
|
}
|
|
@@ -377,221 +333,203 @@ class InstrumentVelocity extends InstrumentBase {
|
|
|
377
333
|
this.averageVelocity = _cloneDeep(result.averageVelocity);
|
|
378
334
|
}
|
|
379
335
|
}
|
|
336
|
+
maxVelocity = 0;
|
|
337
|
+
delta = 0;
|
|
338
|
+
velocity = 0;
|
|
339
|
+
va = 0;
|
|
340
|
+
timeStamp = 0;
|
|
341
|
+
countDiff = 0;
|
|
342
|
+
timeDiff = 0;
|
|
343
|
+
deltaCountDiff = 0;
|
|
344
|
+
deltaTimeDif = 0;
|
|
345
|
+
averageVelocity = [];
|
|
346
|
+
val = 0;
|
|
380
347
|
WithValStackMaxLength(valStackMaxLength) {
|
|
381
|
-
|
|
382
|
-
|
|
348
|
+
this.#valStackMaxLength = valStackMaxLength;
|
|
349
|
+
this.#valStack = [];
|
|
383
350
|
return this;
|
|
384
351
|
}
|
|
385
352
|
_StartTimer() {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
let pushVal =
|
|
389
|
-
for (let i = 0; i <
|
|
390
|
-
if (!
|
|
391
|
-
|
|
353
|
+
this.#interval = setInterval(() => {
|
|
354
|
+
this.#ComputeVelocity();
|
|
355
|
+
let pushVal = this.#velocity;
|
|
356
|
+
for (let i = 0; i < this.#maxAverageIterations; i++) {
|
|
357
|
+
if (!this.#averageValStack[i]) {
|
|
358
|
+
this.#averageValStack[i] = [];
|
|
392
359
|
}
|
|
393
|
-
|
|
394
|
-
if (
|
|
395
|
-
|
|
360
|
+
this.#averageValStack[i].push(pushVal);
|
|
361
|
+
if (this.#averageValStack[i].length > this.#maxAverageValStack) {
|
|
362
|
+
this.#averageValStack[i].shift();
|
|
396
363
|
}
|
|
397
|
-
pushVal =
|
|
398
|
-
|
|
364
|
+
pushVal = this.#averageValStack[i].reduce((prev, current) => prev + current) / this.#averageValStack[i].length;
|
|
365
|
+
this.#averageVelocity[i] = pushVal;
|
|
399
366
|
}
|
|
400
|
-
},
|
|
367
|
+
}, this.#timerInterval);
|
|
401
368
|
if (isNode) {
|
|
402
|
-
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
}
|
|
428
|
-
_val = new WeakMap();
|
|
429
|
-
_interval = new WeakMap();
|
|
430
|
-
_timeoutComputeVelocity = new WeakMap();
|
|
431
|
-
_lastVelocity = new WeakMap();
|
|
432
|
-
_delta = new WeakMap();
|
|
433
|
-
_maxVelocity = new WeakMap();
|
|
434
|
-
_timerInterval = new WeakMap();
|
|
435
|
-
_copy = new WeakMap();
|
|
436
|
-
_velocity = new WeakMap();
|
|
437
|
-
_velocityVal = new WeakMap();
|
|
438
|
-
_valStack = new WeakMap();
|
|
439
|
-
_averageValStack = new WeakMap();
|
|
440
|
-
_maxAverageValStack = new WeakMap();
|
|
441
|
-
_maxAverageIterations = new WeakMap();
|
|
442
|
-
_valStackMaxLength = new WeakMap();
|
|
443
|
-
_valStackAverage = new WeakMap();
|
|
444
|
-
_timeStamp = new WeakMap();
|
|
445
|
-
_maxTimeDiff = new WeakMap();
|
|
446
|
-
_vaTimeDiff = new WeakMap();
|
|
447
|
-
_velocityTimeDiff = new WeakMap();
|
|
448
|
-
_autoComputeVelocity = new WeakMap();
|
|
449
|
-
_autoComputeVelocityTimeout = new WeakMap();
|
|
450
|
-
_countDiff = new WeakMap();
|
|
451
|
-
_timeDiff = new WeakMap();
|
|
452
|
-
_deltaCountDiff = new WeakMap();
|
|
453
|
-
_deltaTimeDif = new WeakMap();
|
|
454
|
-
_minTimeForReporting = new WeakMap();
|
|
455
|
-
_averageVelocity = new WeakMap();
|
|
456
|
-
_InstrumentVelocity_instances = new WeakSet();
|
|
457
|
-
ComputeVelocityByTimeDiff_fn = function(checkTimeDiff, checkDeltaTimeDiff) {
|
|
458
|
-
let val = 0;
|
|
459
|
-
let deltaVal = 0;
|
|
460
|
-
let countDiff = 0;
|
|
461
|
-
let timeDiff = 0;
|
|
462
|
-
let deltaCountDiff = 0;
|
|
463
|
-
let deltaTimeDiff = 0;
|
|
464
|
-
if (__privateGet(this, _valStack).length > 1 && __privateGet(this, _valStack)[__privateGet(this, _valStack).length - 1].timeStamp - __privateGet(this, _valStack)[0].timeStamp > __privateGet(this, _minTimeForReporting)) {
|
|
465
|
-
const dp = __privateGet(this, _valStack)[__privateGet(this, _valStack).length - 1];
|
|
466
|
-
let timeDiffPos = -1;
|
|
467
|
-
let deltaDiffPos = -1;
|
|
468
|
-
for (let i = __privateGet(this, _valStack).length - 2; i > -1; i--) {
|
|
469
|
-
if (timeDiffPos === -1 && __privateGet(this, _timeStamp) - __privateGet(this, _valStack)[i].timeStamp >= checkTimeDiff) {
|
|
470
|
-
timeDiffPos = i;
|
|
471
|
-
if (checkDeltaTimeDiff === 0) {
|
|
369
|
+
this.#interval.unref();
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
#ComputeVelocityByTimeDiff(checkTimeDiff, checkDeltaTimeDiff) {
|
|
373
|
+
let val = 0;
|
|
374
|
+
let deltaVal = 0;
|
|
375
|
+
let countDiff = 0;
|
|
376
|
+
let timeDiff = 0;
|
|
377
|
+
let deltaCountDiff = 0;
|
|
378
|
+
let deltaTimeDiff = 0;
|
|
379
|
+
if (this.#valStack.length > 1 && this.#valStack[this.#valStack.length - 1].timeStamp - this.#valStack[0].timeStamp > this.#minTimeForReporting) {
|
|
380
|
+
const dp = this.#valStack[this.#valStack.length - 1];
|
|
381
|
+
let timeDiffPos = -1;
|
|
382
|
+
let deltaDiffPos = -1;
|
|
383
|
+
for (let i = this.#valStack.length - 2; i > -1; i--) {
|
|
384
|
+
if (timeDiffPos === -1 && this.#timeStamp - this.#valStack[i].timeStamp >= checkTimeDiff) {
|
|
385
|
+
timeDiffPos = i;
|
|
386
|
+
if (checkDeltaTimeDiff === 0) {
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
if (deltaDiffPos === -1 && this.#timeStamp - this.#valStack[i].timeStamp >= checkDeltaTimeDiff) {
|
|
391
|
+
deltaDiffPos = i;
|
|
392
|
+
}
|
|
393
|
+
if (timeDiffPos !== -1 && deltaDiffPos !== -1) {
|
|
472
394
|
break;
|
|
473
395
|
}
|
|
474
396
|
}
|
|
475
|
-
if (
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
if (countDiff > 0) {
|
|
485
|
-
timeDiff = dp.timeStamp - __privateGet(this, _valStack)[timeDiffPos].timeStamp;
|
|
486
|
-
if (timeDiff > 0) {
|
|
487
|
-
val = 1e3 / timeDiff * countDiff;
|
|
397
|
+
if (timeDiffPos > -1) {
|
|
398
|
+
countDiff = dp.count - this.#valStack[timeDiffPos].count;
|
|
399
|
+
if (countDiff > 0) {
|
|
400
|
+
timeDiff = dp.timeStamp - this.#valStack[timeDiffPos].timeStamp;
|
|
401
|
+
if (timeDiff > 0) {
|
|
402
|
+
val = 1e3 / timeDiff * countDiff;
|
|
403
|
+
} else {
|
|
404
|
+
val = 0;
|
|
405
|
+
}
|
|
488
406
|
} else {
|
|
489
407
|
val = 0;
|
|
490
408
|
}
|
|
491
409
|
} else {
|
|
492
410
|
val = 0;
|
|
493
411
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
412
|
+
if (deltaDiffPos > -1) {
|
|
413
|
+
deltaCountDiff = this.#valStack[timeDiffPos].count - this.#valStack[deltaDiffPos].count;
|
|
414
|
+
if (deltaCountDiff > 0) {
|
|
415
|
+
deltaTimeDiff = this.#valStack[timeDiffPos].timeStamp - this.#valStack[deltaDiffPos].timeStamp;
|
|
416
|
+
if (deltaTimeDiff > 0) {
|
|
417
|
+
deltaVal = 1e3 / deltaTimeDiff * deltaTimeDiff;
|
|
418
|
+
} else {
|
|
419
|
+
deltaVal = 0;
|
|
420
|
+
}
|
|
503
421
|
} else {
|
|
504
422
|
deltaVal = 0;
|
|
505
423
|
}
|
|
506
424
|
} else {
|
|
507
425
|
deltaVal = 0;
|
|
508
426
|
}
|
|
427
|
+
}
|
|
428
|
+
return {
|
|
429
|
+
val,
|
|
430
|
+
countDiff,
|
|
431
|
+
timeDiff,
|
|
432
|
+
deltaVal,
|
|
433
|
+
deltaCountDiff,
|
|
434
|
+
deltaTimeDiff
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
#ComputeVelocity() {
|
|
438
|
+
const dp = {
|
|
439
|
+
timeStamp: performance.now(),
|
|
440
|
+
count: this.#velocityVal
|
|
441
|
+
};
|
|
442
|
+
this.#valStack.push(dp);
|
|
443
|
+
this.#timeStamp = dp.timeStamp;
|
|
444
|
+
while (this.#valStack.length > 0 && this.#timeStamp - this.#valStack[0].timeStamp > this.#maxTimeDiff) {
|
|
445
|
+
this.#valStack.shift();
|
|
446
|
+
}
|
|
447
|
+
const valStackAverageDataPoint = this.#ComputeVelocityByTimeDiff(this.#vaTimeDiff, 0);
|
|
448
|
+
this.#valStackAverage = valStackAverageDataPoint.val;
|
|
449
|
+
const velocityDataPoint = this.#ComputeVelocityByTimeDiff(this.#velocityTimeDiff, this.#velocityTimeDiff * 2);
|
|
450
|
+
this.#velocity = velocityDataPoint.val;
|
|
451
|
+
this.#delta = velocityDataPoint.val - velocityDataPoint.deltaVal;
|
|
452
|
+
this.#countDiff = velocityDataPoint.countDiff;
|
|
453
|
+
this.#timeDiff = velocityDataPoint.timeDiff;
|
|
454
|
+
this.#deltaCountDiff = velocityDataPoint.deltaCountDiff;
|
|
455
|
+
this.#deltaTimeDif = velocityDataPoint.deltaTimeDiff;
|
|
456
|
+
this.#lastVelocity = this.#velocity;
|
|
457
|
+
if (this.#velocity > this.#maxVelocity) {
|
|
458
|
+
this.#maxVelocity = this.#velocity;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
#SetupAutoComputeVelocity() {
|
|
462
|
+
if (this.#timeoutComputeVelocity) {
|
|
463
|
+
clearTimeout(this.#timeoutComputeVelocity);
|
|
464
|
+
}
|
|
465
|
+
this.#timeoutComputeVelocity = setTimeout(() => {
|
|
466
|
+
this.#ComputeVelocity();
|
|
467
|
+
}, this.#autoComputeVelocityTimeout);
|
|
468
|
+
}
|
|
469
|
+
#GetVelocityStackAverage() {
|
|
470
|
+
return this.GetNumber(this.#valStackAverage);
|
|
471
|
+
}
|
|
472
|
+
Inc(incVal = 1) {
|
|
473
|
+
this.#velocityVal += incVal;
|
|
474
|
+
if (this.#autoComputeVelocity) {
|
|
475
|
+
this.#ComputeVelocity();
|
|
509
476
|
} else {
|
|
510
|
-
|
|
477
|
+
this.#SetupAutoComputeVelocity();
|
|
511
478
|
}
|
|
512
479
|
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
countDiff,
|
|
516
|
-
timeDiff,
|
|
517
|
-
deltaVal,
|
|
518
|
-
deltaCountDiff,
|
|
519
|
-
deltaTimeDiff
|
|
520
|
-
};
|
|
521
|
-
};
|
|
522
|
-
ComputeVelocity_fn = function() {
|
|
523
|
-
const dp = {
|
|
524
|
-
timeStamp: performance.now(),
|
|
525
|
-
count: __privateGet(this, _velocityVal)
|
|
526
|
-
};
|
|
527
|
-
__privateGet(this, _valStack).push(dp);
|
|
528
|
-
__privateSet(this, _timeStamp, dp.timeStamp);
|
|
529
|
-
while (__privateGet(this, _valStack).length > 0 && __privateGet(this, _timeStamp) - __privateGet(this, _valStack)[0].timeStamp > __privateGet(this, _maxTimeDiff)) {
|
|
530
|
-
__privateGet(this, _valStack).shift();
|
|
531
|
-
}
|
|
532
|
-
const valStackAverageDataPoint = __privateMethod(this, _InstrumentVelocity_instances, ComputeVelocityByTimeDiff_fn).call(this, __privateGet(this, _vaTimeDiff), 0);
|
|
533
|
-
__privateSet(this, _valStackAverage, valStackAverageDataPoint.val);
|
|
534
|
-
const velocityDataPoint = __privateMethod(this, _InstrumentVelocity_instances, ComputeVelocityByTimeDiff_fn).call(this, __privateGet(this, _velocityTimeDiff), __privateGet(this, _velocityTimeDiff) * 2);
|
|
535
|
-
__privateSet(this, _velocity, velocityDataPoint.val);
|
|
536
|
-
__privateSet(this, _delta, velocityDataPoint.val - velocityDataPoint.deltaVal);
|
|
537
|
-
__privateSet(this, _countDiff, velocityDataPoint.countDiff);
|
|
538
|
-
__privateSet(this, _timeDiff, velocityDataPoint.timeDiff);
|
|
539
|
-
__privateSet(this, _deltaCountDiff, velocityDataPoint.deltaCountDiff);
|
|
540
|
-
__privateSet(this, _deltaTimeDif, velocityDataPoint.deltaTimeDiff);
|
|
541
|
-
__privateSet(this, _lastVelocity, __privateGet(this, _velocity));
|
|
542
|
-
if (__privateGet(this, _velocity) > __privateGet(this, _maxVelocity)) {
|
|
543
|
-
__privateSet(this, _maxVelocity, __privateGet(this, _velocity));
|
|
480
|
+
#GetVal() {
|
|
481
|
+
return this.GetNumber(this.#velocityVal);
|
|
544
482
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
483
|
+
#SetVal(updatedValue) {
|
|
484
|
+
this.#velocityVal = updatedValue;
|
|
485
|
+
if (this.#autoComputeVelocity) {
|
|
486
|
+
this.#ComputeVelocity();
|
|
487
|
+
} else {
|
|
488
|
+
this.#SetupAutoComputeVelocity();
|
|
489
|
+
}
|
|
549
490
|
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
}, __privateGet(this, _autoComputeVelocityTimeout)));
|
|
553
|
-
};
|
|
554
|
-
GetVelocityStackAverage_fn = function() {
|
|
555
|
-
return this.GetNumber(__privateGet(this, _valStackAverage));
|
|
556
|
-
};
|
|
557
|
-
GetVal_fn = function() {
|
|
558
|
-
return this.GetNumber(__privateGet(this, _velocityVal));
|
|
559
|
-
};
|
|
560
|
-
SetVal_fn = function(updatedValue) {
|
|
561
|
-
__privateSet(this, _velocityVal, updatedValue);
|
|
562
|
-
if (__privateGet(this, _autoComputeVelocity)) {
|
|
563
|
-
__privateMethod(this, _InstrumentVelocity_instances, ComputeVelocity_fn).call(this);
|
|
564
|
-
} else {
|
|
565
|
-
__privateMethod(this, _InstrumentVelocity_instances, SetupAutoComputeVelocity_fn).call(this);
|
|
491
|
+
#GetVelocity() {
|
|
492
|
+
return this.GetNumber(this.#velocity);
|
|
566
493
|
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
494
|
+
#GetMaxVelocity() {
|
|
495
|
+
return this.GetNumber(this.#maxVelocity);
|
|
496
|
+
}
|
|
497
|
+
#GetDelta() {
|
|
498
|
+
return this.GetNumber(this.#delta);
|
|
499
|
+
}
|
|
500
|
+
#GetTimeStamp() {
|
|
501
|
+
return this.GetNumber(this.#timeStamp);
|
|
502
|
+
}
|
|
503
|
+
#GetCountDiff() {
|
|
504
|
+
return this.GetNumber(this.#countDiff);
|
|
505
|
+
}
|
|
506
|
+
#GetTimeDiff() {
|
|
507
|
+
return this.GetNumber(this.#timeDiff);
|
|
508
|
+
}
|
|
509
|
+
#GetDeltaCountDiff() {
|
|
510
|
+
return this.GetNumber(this.#deltaCountDiff);
|
|
511
|
+
}
|
|
512
|
+
#GetDeltaTimeDif() {
|
|
513
|
+
return this.GetNumber(this.#deltaTimeDif);
|
|
514
|
+
}
|
|
515
|
+
#GetAverageVelocity() {
|
|
516
|
+
return this.#averageVelocity;
|
|
517
|
+
}
|
|
518
|
+
StopTimer() {
|
|
519
|
+
if (this.#interval !== null) {
|
|
520
|
+
clearTimeout(this.#interval);
|
|
521
|
+
this.#interval = null;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
ProcessTelemetry(telemetry) {
|
|
525
|
+
if (telemetry.Inc !== void 0) {
|
|
526
|
+
this.Inc(telemetry.Inc);
|
|
527
|
+
}
|
|
528
|
+
if (telemetry.val !== void 0) {
|
|
529
|
+
this.val = telemetry.val;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
595
533
|
var HistogramDataElementPos = /* @__PURE__ */ ((HistogramDataElementPos2) => {
|
|
596
534
|
HistogramDataElementPos2[HistogramDataElementPos2["val"] = 0] = "val";
|
|
597
535
|
HistogramDataElementPos2[HistogramDataElementPos2["label"] = 1] = "label";
|
|
@@ -599,28 +537,19 @@ var HistogramDataElementPos = /* @__PURE__ */ ((HistogramDataElementPos2) => {
|
|
|
599
537
|
return HistogramDataElementPos2;
|
|
600
538
|
})(HistogramDataElementPos || {});
|
|
601
539
|
class InstrumentHistogramOptions extends InstrumentBaseOptions {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
__publicField(this, "initValue");
|
|
606
|
-
__publicField(this, "fromJSON");
|
|
607
|
-
}
|
|
540
|
+
histogramData;
|
|
541
|
+
initValue;
|
|
542
|
+
fromJSON;
|
|
608
543
|
}
|
|
609
544
|
class InstrumentHistogramTelemetry extends InstrumentBaseTelemetry {
|
|
610
|
-
|
|
611
|
-
super(...arguments);
|
|
612
|
-
__publicField(this, "val");
|
|
613
|
-
}
|
|
545
|
+
val;
|
|
614
546
|
}
|
|
615
547
|
class InstrumentHistogram extends InstrumentBase {
|
|
548
|
+
#histogramData = [];
|
|
549
|
+
#val = 0;
|
|
550
|
+
#copy = false;
|
|
616
551
|
constructor(options = {}) {
|
|
617
552
|
super(options);
|
|
618
|
-
__privateAdd(this, _InstrumentHistogram_instances);
|
|
619
|
-
__privateAdd(this, _histogramData, []);
|
|
620
|
-
__privateAdd(this, _val2, 0);
|
|
621
|
-
__privateAdd(this, _copy2, false);
|
|
622
|
-
__publicField(this, "hist", []);
|
|
623
|
-
__publicField(this, "val", 0);
|
|
624
553
|
if (typeof options.label === "undefined") {
|
|
625
554
|
this.label = "InstrumentHistogram";
|
|
626
555
|
} else {
|
|
@@ -633,12 +562,12 @@ class InstrumentHistogram extends InstrumentBase {
|
|
|
633
562
|
histogramData = options.histogramData;
|
|
634
563
|
}
|
|
635
564
|
if (typeof options.fromJSON === "undefined") {
|
|
636
|
-
|
|
565
|
+
this.#copy = false;
|
|
637
566
|
} else {
|
|
638
|
-
|
|
567
|
+
this.#copy = true;
|
|
639
568
|
}
|
|
640
569
|
if (histogramData === null) {
|
|
641
|
-
|
|
570
|
+
this.#histogramData = [
|
|
642
571
|
[0, "10", 10],
|
|
643
572
|
[0, "20", 20],
|
|
644
573
|
[0, "50", 50],
|
|
@@ -646,13 +575,13 @@ class InstrumentHistogram extends InstrumentBase {
|
|
|
646
575
|
[0, "1000", 1e3],
|
|
647
576
|
[0, "5000", 5e3],
|
|
648
577
|
[0, "EE", 0]
|
|
649
|
-
]
|
|
578
|
+
];
|
|
650
579
|
} else if (Array.isArray(histogramData)) {
|
|
651
|
-
|
|
580
|
+
this.#histogramData = [];
|
|
652
581
|
for (let i = 0; i < histogramData.length; i++) {
|
|
653
|
-
|
|
582
|
+
this.#histogramData.push([0, "" + histogramData[i], parseFloat(histogramData[i].toString())]);
|
|
654
583
|
}
|
|
655
|
-
|
|
584
|
+
this.#histogramData.push([0, "EE", 0]);
|
|
656
585
|
} else {
|
|
657
586
|
throw new Error(`Passed [${histogramData}] must be an array.`);
|
|
658
587
|
}
|
|
@@ -660,7 +589,7 @@ class InstrumentHistogram extends InstrumentBase {
|
|
|
660
589
|
enumerable: true,
|
|
661
590
|
get: () => GaugeTypes.INSTRUMENT_HISTOGRAM
|
|
662
591
|
});
|
|
663
|
-
if (
|
|
592
|
+
if (this.#copy) {
|
|
664
593
|
this.DefineCopyProperties([
|
|
665
594
|
"val",
|
|
666
595
|
"hist"
|
|
@@ -668,30 +597,32 @@ class InstrumentHistogram extends InstrumentBase {
|
|
|
668
597
|
} else {
|
|
669
598
|
Object.defineProperty(this, "val", {
|
|
670
599
|
enumerable: true,
|
|
671
|
-
get: () =>
|
|
600
|
+
get: () => this.#GetVal(),
|
|
672
601
|
set: (value) => {
|
|
673
|
-
|
|
602
|
+
this.#SetVal(value);
|
|
674
603
|
}
|
|
675
604
|
});
|
|
676
605
|
Object.defineProperty(this, "hist", {
|
|
677
606
|
enumerable: true,
|
|
678
|
-
get: () =>
|
|
607
|
+
get: () => this.#GetHistogramData(),
|
|
679
608
|
set: (value) => {
|
|
680
|
-
|
|
609
|
+
this.#SetHistogramData(value);
|
|
681
610
|
}
|
|
682
611
|
});
|
|
683
612
|
}
|
|
684
613
|
if (typeof options.initValue !== "undefined") {
|
|
685
|
-
|
|
614
|
+
this.#val = options.initValue;
|
|
686
615
|
}
|
|
687
616
|
if (typeof options.fromJSON !== "undefined") {
|
|
688
617
|
const result = _cloneDeep(options.fromJSON);
|
|
689
|
-
|
|
618
|
+
this.#val = result.val;
|
|
690
619
|
this.hist = result.hist;
|
|
691
620
|
}
|
|
692
621
|
}
|
|
622
|
+
hist = [];
|
|
623
|
+
val = 0;
|
|
693
624
|
WithInitVal(initVal) {
|
|
694
|
-
|
|
625
|
+
this.#val = initVal;
|
|
695
626
|
return this;
|
|
696
627
|
}
|
|
697
628
|
ResetHistogramData() {
|
|
@@ -700,27 +631,34 @@ class InstrumentHistogram extends InstrumentBase {
|
|
|
700
631
|
}
|
|
701
632
|
}
|
|
702
633
|
AddObservation(updateValue) {
|
|
703
|
-
if (
|
|
634
|
+
if (this.#copy) {
|
|
704
635
|
throw new Error("Cannot add observations from the copy version of this class.");
|
|
705
636
|
}
|
|
706
637
|
let i = 0;
|
|
707
|
-
for (; i <
|
|
708
|
-
if (updateValue <=
|
|
638
|
+
for (; i < this.#histogramData.length - 1; i++) {
|
|
639
|
+
if (updateValue <= this.#histogramData[i][
|
|
709
640
|
2
|
|
710
641
|
/* breakPoint */
|
|
711
642
|
]) {
|
|
712
|
-
|
|
643
|
+
this.#histogramData[i][
|
|
713
644
|
0
|
|
714
645
|
/* val */
|
|
715
646
|
]++;
|
|
716
647
|
return;
|
|
717
648
|
}
|
|
718
649
|
}
|
|
719
|
-
|
|
650
|
+
this.#histogramData[i][
|
|
720
651
|
0
|
|
721
652
|
/* val */
|
|
722
653
|
]++;
|
|
723
654
|
}
|
|
655
|
+
#GetVal() {
|
|
656
|
+
return this.GetNumber(this.#val);
|
|
657
|
+
}
|
|
658
|
+
#SetVal(value) {
|
|
659
|
+
this.#val = value;
|
|
660
|
+
this.AddObservation(value);
|
|
661
|
+
}
|
|
724
662
|
get formattedHistogramData() {
|
|
725
663
|
let retVal = "";
|
|
726
664
|
let sep = "";
|
|
@@ -736,6 +674,12 @@ class InstrumentHistogram extends InstrumentBase {
|
|
|
736
674
|
}
|
|
737
675
|
return retVal;
|
|
738
676
|
}
|
|
677
|
+
#GetHistogramData() {
|
|
678
|
+
return this.#histogramData;
|
|
679
|
+
}
|
|
680
|
+
#SetHistogramData(value) {
|
|
681
|
+
this.#histogramData = value;
|
|
682
|
+
}
|
|
739
683
|
static AddHistogramDataEx(histoA, histoB) {
|
|
740
684
|
if (histoA === null) {
|
|
741
685
|
return _cloneDeep(histoB);
|
|
@@ -820,109 +764,84 @@ class InstrumentHistogram extends InstrumentBase {
|
|
|
820
764
|
}
|
|
821
765
|
}
|
|
822
766
|
}
|
|
823
|
-
_histogramData = new WeakMap();
|
|
824
|
-
_val2 = new WeakMap();
|
|
825
|
-
_copy2 = new WeakMap();
|
|
826
|
-
_InstrumentHistogram_instances = new WeakSet();
|
|
827
|
-
GetVal_fn2 = function() {
|
|
828
|
-
return this.GetNumber(__privateGet(this, _val2));
|
|
829
|
-
};
|
|
830
|
-
SetVal_fn2 = function(value) {
|
|
831
|
-
__privateSet(this, _val2, value);
|
|
832
|
-
this.AddObservation(value);
|
|
833
|
-
};
|
|
834
|
-
GetHistogramData_fn = function() {
|
|
835
|
-
return __privateGet(this, _histogramData);
|
|
836
|
-
};
|
|
837
|
-
SetHistogramData_fn = function(value) {
|
|
838
|
-
__privateSet(this, _histogramData, value);
|
|
839
|
-
};
|
|
840
767
|
class InstrumentLogOptions extends InstrumentBaseOptions {
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
__publicField(this, "initValue");
|
|
850
|
-
__publicField(this, "logger");
|
|
851
|
-
}
|
|
768
|
+
maxSize;
|
|
769
|
+
useLatestMessages;
|
|
770
|
+
consoleLogging;
|
|
771
|
+
instrumentLogging;
|
|
772
|
+
winstonLogging;
|
|
773
|
+
fromJSON;
|
|
774
|
+
initValue;
|
|
775
|
+
logger;
|
|
852
776
|
}
|
|
853
777
|
class InstrumentLogTelemetry extends InstrumentBaseTelemetry {
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
__publicField(this, "val");
|
|
859
|
-
__publicField(this, "ResetLog");
|
|
860
|
-
}
|
|
778
|
+
Append;
|
|
779
|
+
LogMessage;
|
|
780
|
+
val;
|
|
781
|
+
ResetLog;
|
|
861
782
|
}
|
|
862
783
|
class InstrumentLog extends InstrumentBase {
|
|
784
|
+
#messages = [];
|
|
785
|
+
#readPos = 0;
|
|
786
|
+
#maxSize = 200;
|
|
787
|
+
// Max length of cached log messages
|
|
788
|
+
#copy = false;
|
|
789
|
+
#useLatestMessages = false;
|
|
790
|
+
#consoleLogging = false;
|
|
791
|
+
#instrumentLogging = true;
|
|
792
|
+
#winstonLogging = false;
|
|
793
|
+
#stsLogger;
|
|
863
794
|
constructor(options = {}) {
|
|
864
795
|
super(options);
|
|
865
|
-
__privateAdd(this, _InstrumentLog_instances);
|
|
866
|
-
__privateAdd(this, _messages, []);
|
|
867
|
-
__privateAdd(this, _readPos, 0);
|
|
868
|
-
__privateAdd(this, _maxSize, 200);
|
|
869
|
-
// Max length of cached log messages
|
|
870
|
-
__privateAdd(this, _copy3, false);
|
|
871
|
-
__privateAdd(this, _useLatestMessages, false);
|
|
872
|
-
__privateAdd(this, _consoleLogging, false);
|
|
873
|
-
__privateAdd(this, _instrumentLogging, true);
|
|
874
|
-
__privateAdd(this, _winstonLogging, false);
|
|
875
|
-
__privateAdd(this, _stsLogger);
|
|
876
|
-
__publicField(this, "val", []);
|
|
877
796
|
if (typeof options.label === "undefined") {
|
|
878
797
|
this.label = "InstrumentLog";
|
|
879
798
|
} else {
|
|
880
799
|
this.label = options.label;
|
|
881
800
|
}
|
|
882
801
|
if (typeof options.maxSize === "undefined") {
|
|
883
|
-
|
|
802
|
+
this.#maxSize = 200;
|
|
884
803
|
} else {
|
|
885
|
-
|
|
804
|
+
this.#maxSize = options.maxSize;
|
|
886
805
|
}
|
|
887
806
|
if (typeof options.fromJSON === "undefined") {
|
|
888
|
-
|
|
807
|
+
this.#copy = false;
|
|
889
808
|
} else {
|
|
890
|
-
|
|
809
|
+
this.#copy = true;
|
|
891
810
|
}
|
|
892
811
|
if (typeof options.useLatestMessages === "undefined") {
|
|
893
|
-
|
|
812
|
+
this.#useLatestMessages = false;
|
|
894
813
|
} else {
|
|
895
|
-
|
|
814
|
+
this.#useLatestMessages = options.useLatestMessages;
|
|
896
815
|
}
|
|
897
816
|
if (typeof options.consoleLogging === "undefined") {
|
|
898
|
-
|
|
817
|
+
this.#consoleLogging = false;
|
|
899
818
|
} else {
|
|
900
|
-
|
|
819
|
+
this.#consoleLogging = options.consoleLogging;
|
|
901
820
|
}
|
|
902
821
|
if (typeof options.instrumentLogging === "undefined") {
|
|
903
|
-
|
|
822
|
+
this.#instrumentLogging = true;
|
|
904
823
|
} else {
|
|
905
|
-
|
|
824
|
+
this.#instrumentLogging = options.instrumentLogging;
|
|
906
825
|
}
|
|
907
826
|
if (typeof options.winstonLogging === "undefined") {
|
|
908
|
-
|
|
827
|
+
this.#winstonLogging = false;
|
|
909
828
|
} else {
|
|
910
|
-
|
|
829
|
+
this.#winstonLogging = options.winstonLogging;
|
|
911
830
|
}
|
|
912
831
|
Object.defineProperty(this, GaugeTypes.GAUGE_TYPE, {
|
|
913
832
|
enumerable: true,
|
|
914
833
|
get: () => GaugeTypes.INSTRUMENT_LOG
|
|
915
834
|
});
|
|
916
|
-
if (
|
|
835
|
+
if (this.#copy) {
|
|
917
836
|
this.DefineCopyProperties([
|
|
918
837
|
"val"
|
|
919
838
|
]);
|
|
920
839
|
} else {
|
|
921
840
|
Object.defineProperty(this, "val", {
|
|
922
841
|
enumerable: true,
|
|
923
|
-
get: () => _cloneDeep(
|
|
842
|
+
get: () => _cloneDeep(this.#GetVal()),
|
|
924
843
|
set: (value) => {
|
|
925
|
-
|
|
844
|
+
this.#SetVal(value);
|
|
926
845
|
}
|
|
927
846
|
});
|
|
928
847
|
}
|
|
@@ -934,42 +853,49 @@ class InstrumentLog extends InstrumentBase {
|
|
|
934
853
|
this.val = result.val;
|
|
935
854
|
}
|
|
936
855
|
}
|
|
856
|
+
val = [];
|
|
937
857
|
WithMaxSize(maxSize) {
|
|
938
|
-
|
|
858
|
+
this.#maxSize = maxSize;
|
|
939
859
|
return this;
|
|
940
860
|
}
|
|
941
861
|
WithUseLatestMessages(useLatestMessages) {
|
|
942
|
-
|
|
862
|
+
this.#useLatestMessages = useLatestMessages;
|
|
943
863
|
return this;
|
|
944
864
|
}
|
|
945
865
|
WithConsoleLogging(consoleLogging2) {
|
|
946
|
-
|
|
866
|
+
this.#consoleLogging = consoleLogging2;
|
|
947
867
|
return this;
|
|
948
868
|
}
|
|
949
869
|
WithInstrumentLogging(instrumentLogging2) {
|
|
950
|
-
|
|
870
|
+
this.#instrumentLogging = instrumentLogging2;
|
|
951
871
|
return this;
|
|
952
872
|
}
|
|
953
873
|
get MaxSize() {
|
|
954
|
-
return
|
|
874
|
+
return this.#maxSize;
|
|
955
875
|
}
|
|
956
876
|
set MaxSize(maxSize) {
|
|
957
|
-
|
|
877
|
+
this.#maxSize = maxSize;
|
|
878
|
+
}
|
|
879
|
+
#DumpToConsole() {
|
|
880
|
+
const logReport = this.GetMessagesSinceLastRead();
|
|
881
|
+
for (let i = 0; i < logReport.length; i++) {
|
|
882
|
+
console.log(logReport[i]);
|
|
883
|
+
}
|
|
958
884
|
}
|
|
959
885
|
get consoleLogging() {
|
|
960
|
-
return
|
|
886
|
+
return this.#consoleLogging;
|
|
961
887
|
}
|
|
962
888
|
set consoleLogging(value) {
|
|
963
|
-
|
|
889
|
+
this.#consoleLogging = value;
|
|
964
890
|
if (value === true) {
|
|
965
|
-
|
|
891
|
+
this.#DumpToConsole();
|
|
966
892
|
}
|
|
967
893
|
}
|
|
968
894
|
get instrumentLogging() {
|
|
969
|
-
return
|
|
895
|
+
return this.#instrumentLogging;
|
|
970
896
|
}
|
|
971
897
|
set instrumentLogging(value) {
|
|
972
|
-
|
|
898
|
+
this.#instrumentLogging = value;
|
|
973
899
|
}
|
|
974
900
|
Append(messageArray) {
|
|
975
901
|
for (let i = 0; i < messageArray.length; i++) {
|
|
@@ -977,54 +903,65 @@ class InstrumentLog extends InstrumentBase {
|
|
|
977
903
|
}
|
|
978
904
|
}
|
|
979
905
|
error(message) {
|
|
980
|
-
if (
|
|
906
|
+
if (this.#winstonLogging && this.#stsLogger) this.#stsLogger.error(message);
|
|
981
907
|
}
|
|
982
908
|
warn(message) {
|
|
983
|
-
if (
|
|
909
|
+
if (this.#winstonLogging && this.#stsLogger) this.#stsLogger.warn(message);
|
|
984
910
|
}
|
|
985
911
|
info(message) {
|
|
986
|
-
if (
|
|
912
|
+
if (this.#winstonLogging && this.#stsLogger) this.#stsLogger.info(message);
|
|
987
913
|
}
|
|
988
914
|
http(message) {
|
|
989
|
-
if (
|
|
915
|
+
if (this.#winstonLogging && this.#stsLogger) this.#stsLogger.http(message);
|
|
990
916
|
}
|
|
991
917
|
verbose(message) {
|
|
992
|
-
if (
|
|
918
|
+
if (this.#winstonLogging && this.#stsLogger) this.#stsLogger.verbose(message);
|
|
993
919
|
}
|
|
994
920
|
debug(message) {
|
|
995
|
-
if (
|
|
921
|
+
if (this.#winstonLogging && this.#stsLogger) this.#stsLogger.debug(message);
|
|
996
922
|
}
|
|
997
923
|
silly(message) {
|
|
998
|
-
if (
|
|
924
|
+
if (this.#winstonLogging && this.#stsLogger) this.#stsLogger.silly(message);
|
|
999
925
|
}
|
|
1000
926
|
LogMessage(message) {
|
|
1001
|
-
if (
|
|
927
|
+
if (this.#copy) {
|
|
1002
928
|
throw new Error("Cannot add log messages from the copy version of this class.");
|
|
1003
929
|
}
|
|
1004
|
-
if (
|
|
930
|
+
if (this.#consoleLogging === true) {
|
|
1005
931
|
console.log(message);
|
|
1006
932
|
}
|
|
1007
|
-
if (
|
|
933
|
+
if (this.#instrumentLogging === false) {
|
|
1008
934
|
return;
|
|
1009
935
|
}
|
|
1010
|
-
|
|
1011
|
-
if (
|
|
1012
|
-
|
|
1013
|
-
|
|
936
|
+
this.#messages.push(message);
|
|
937
|
+
if (this.#messages.length > this.#maxSize) {
|
|
938
|
+
this.#messages.shift();
|
|
939
|
+
this.#readPos = this.#readPos > 0 ? this.#readPos - 1 : 0;
|
|
1014
940
|
}
|
|
1015
941
|
}
|
|
942
|
+
#GetVal() {
|
|
943
|
+
if (this.#useLatestMessages) {
|
|
944
|
+
return this.GetMessagesSinceLastRead();
|
|
945
|
+
} else {
|
|
946
|
+
return this.#messages;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
#SetVal(updatedValue) {
|
|
950
|
+
this.#messages = updatedValue;
|
|
951
|
+
this.#readPos = 0;
|
|
952
|
+
}
|
|
1016
953
|
GetMessagesNoUpdate() {
|
|
1017
|
-
return
|
|
954
|
+
return this.#messages.slice(this.#readPos);
|
|
1018
955
|
}
|
|
1019
956
|
// This will return only those messages that have been added since the last read
|
|
1020
957
|
GetMessagesSinceLastRead() {
|
|
1021
|
-
const retVal =
|
|
1022
|
-
|
|
958
|
+
const retVal = this.#messages.slice(this.#readPos);
|
|
959
|
+
this.#readPos = this.#messages.length;
|
|
1023
960
|
return retVal;
|
|
1024
961
|
}
|
|
1025
962
|
ResetLog() {
|
|
1026
|
-
|
|
1027
|
-
|
|
963
|
+
this.#messages = [];
|
|
964
|
+
this.#readPos = 0;
|
|
1028
965
|
}
|
|
1029
966
|
ProcessTelemetry(telemetry) {
|
|
1030
967
|
if (telemetry.val !== void 0) {
|
|
@@ -1041,81 +978,46 @@ class InstrumentLog extends InstrumentBase {
|
|
|
1041
978
|
}
|
|
1042
979
|
}
|
|
1043
980
|
}
|
|
1044
|
-
_messages = new WeakMap();
|
|
1045
|
-
_readPos = new WeakMap();
|
|
1046
|
-
_maxSize = new WeakMap();
|
|
1047
|
-
_copy3 = new WeakMap();
|
|
1048
|
-
_useLatestMessages = new WeakMap();
|
|
1049
|
-
_consoleLogging = new WeakMap();
|
|
1050
|
-
_instrumentLogging = new WeakMap();
|
|
1051
|
-
_winstonLogging = new WeakMap();
|
|
1052
|
-
_stsLogger = new WeakMap();
|
|
1053
|
-
_InstrumentLog_instances = new WeakSet();
|
|
1054
|
-
DumpToConsole_fn = function() {
|
|
1055
|
-
const logReport = this.GetMessagesSinceLastRead();
|
|
1056
|
-
for (let i = 0; i < logReport.length; i++) {
|
|
1057
|
-
console.log(logReport[i]);
|
|
1058
|
-
}
|
|
1059
|
-
};
|
|
1060
|
-
GetVal_fn3 = function() {
|
|
1061
|
-
if (__privateGet(this, _useLatestMessages)) {
|
|
1062
|
-
return this.GetMessagesSinceLastRead();
|
|
1063
|
-
} else {
|
|
1064
|
-
return __privateGet(this, _messages);
|
|
1065
|
-
}
|
|
1066
|
-
};
|
|
1067
|
-
SetVal_fn3 = function(updatedValue) {
|
|
1068
|
-
__privateSet(this, _messages, updatedValue);
|
|
1069
|
-
__privateSet(this, _readPos, 0);
|
|
1070
|
-
};
|
|
1071
981
|
class InstrumentTimerOptions extends InstrumentBaseOptions {
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
__publicField(this, "fromJSON");
|
|
1075
|
-
__publicField(this, "initValue");
|
|
1076
|
-
}
|
|
982
|
+
fromJSON;
|
|
983
|
+
initValue;
|
|
1077
984
|
}
|
|
1078
985
|
class InstrumentTimerTelemetry extends InstrumentBaseTelemetry {
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
__publicField(this, "Resume");
|
|
1084
|
-
__publicField(this, "Reset");
|
|
1085
|
-
}
|
|
986
|
+
val;
|
|
987
|
+
Pause;
|
|
988
|
+
Resume;
|
|
989
|
+
Reset;
|
|
1086
990
|
}
|
|
1087
991
|
class InstrumentTimerGauge extends InstrumentBase {
|
|
992
|
+
#start = 0;
|
|
993
|
+
#copy = false;
|
|
994
|
+
#pauseVal = 0;
|
|
1088
995
|
constructor(options = {}) {
|
|
1089
996
|
super(options);
|
|
1090
|
-
__privateAdd(this, _InstrumentTimerGauge_instances);
|
|
1091
|
-
__privateAdd(this, _start, 0);
|
|
1092
|
-
__privateAdd(this, _copy4, false);
|
|
1093
|
-
__privateAdd(this, _pauseVal, 0);
|
|
1094
|
-
__publicField(this, "val", 0);
|
|
1095
997
|
if (typeof options.label === "undefined") {
|
|
1096
998
|
this.label = "InstrumentTimerGauge";
|
|
1097
999
|
} else {
|
|
1098
1000
|
this.label = options.label;
|
|
1099
1001
|
}
|
|
1100
1002
|
if (typeof options.fromJSON === "undefined") {
|
|
1101
|
-
|
|
1003
|
+
this.#copy = false;
|
|
1102
1004
|
} else {
|
|
1103
|
-
|
|
1005
|
+
this.#copy = true;
|
|
1104
1006
|
}
|
|
1105
1007
|
Object.defineProperty(this, GaugeTypes.GAUGE_TYPE, {
|
|
1106
1008
|
enumerable: true,
|
|
1107
1009
|
get: () => GaugeTypes.INSTRUMENT_TIMER
|
|
1108
1010
|
});
|
|
1109
|
-
if (
|
|
1011
|
+
if (this.#copy) {
|
|
1110
1012
|
this.DefineCopyProperties([
|
|
1111
1013
|
"val"
|
|
1112
1014
|
]);
|
|
1113
1015
|
} else {
|
|
1114
1016
|
Object.defineProperty(this, "val", {
|
|
1115
1017
|
enumerable: true,
|
|
1116
|
-
get: () =>
|
|
1018
|
+
get: () => this.#GetVal(),
|
|
1117
1019
|
set: (value) => {
|
|
1118
|
-
|
|
1020
|
+
this.#SetVal(value);
|
|
1119
1021
|
}
|
|
1120
1022
|
});
|
|
1121
1023
|
}
|
|
@@ -1128,22 +1030,40 @@ class InstrumentTimerGauge extends InstrumentBase {
|
|
|
1128
1030
|
}
|
|
1129
1031
|
this.Reset();
|
|
1130
1032
|
}
|
|
1033
|
+
val = 0;
|
|
1131
1034
|
// Take a snap shot of the current elapsed time. The 'clock' will still keep running.
|
|
1132
1035
|
Pause() {
|
|
1133
|
-
|
|
1036
|
+
this.#pauseVal = this.val;
|
|
1134
1037
|
}
|
|
1135
1038
|
Resume() {
|
|
1136
|
-
|
|
1039
|
+
this.#pauseVal = 0;
|
|
1137
1040
|
}
|
|
1138
1041
|
Reset() {
|
|
1139
1042
|
if (isNode) {
|
|
1140
|
-
|
|
1043
|
+
this.#start = performance.now();
|
|
1044
|
+
} else {
|
|
1045
|
+
this.#start = performance.now();
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
#GetVal() {
|
|
1049
|
+
if (this.#pauseVal !== 0) {
|
|
1050
|
+
return this.GetNumber(this.#pauseVal);
|
|
1051
|
+
}
|
|
1052
|
+
if (isNode) {
|
|
1053
|
+
return this.GetNumber(performance.now() - this.#start);
|
|
1141
1054
|
} else {
|
|
1142
|
-
|
|
1055
|
+
return this.GetNumber(performance.now() - this.#start);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
#SetVal(updatedValue) {
|
|
1059
|
+
if (isNode) {
|
|
1060
|
+
this.#start = performance.now() - updatedValue;
|
|
1061
|
+
} else {
|
|
1062
|
+
this.#start = performance.now() - updatedValue;
|
|
1143
1063
|
}
|
|
1144
1064
|
}
|
|
1145
1065
|
get start() {
|
|
1146
|
-
return
|
|
1066
|
+
return this.#start;
|
|
1147
1067
|
}
|
|
1148
1068
|
/*
|
|
1149
1069
|
#convertMS(ms: number): string {
|
|
@@ -1176,27 +1096,6 @@ class InstrumentTimerGauge extends InstrumentBase {
|
|
|
1176
1096
|
}
|
|
1177
1097
|
}
|
|
1178
1098
|
}
|
|
1179
|
-
_start = new WeakMap();
|
|
1180
|
-
_copy4 = new WeakMap();
|
|
1181
|
-
_pauseVal = new WeakMap();
|
|
1182
|
-
_InstrumentTimerGauge_instances = new WeakSet();
|
|
1183
|
-
GetVal_fn4 = function() {
|
|
1184
|
-
if (__privateGet(this, _pauseVal) !== 0) {
|
|
1185
|
-
return this.GetNumber(__privateGet(this, _pauseVal));
|
|
1186
|
-
}
|
|
1187
|
-
if (isNode) {
|
|
1188
|
-
return this.GetNumber(performance.now() - __privateGet(this, _start));
|
|
1189
|
-
} else {
|
|
1190
|
-
return this.GetNumber(performance.now() - __privateGet(this, _start));
|
|
1191
|
-
}
|
|
1192
|
-
};
|
|
1193
|
-
SetVal_fn4 = function(updatedValue) {
|
|
1194
|
-
if (isNode) {
|
|
1195
|
-
__privateSet(this, _start, performance.now() - updatedValue);
|
|
1196
|
-
} else {
|
|
1197
|
-
__privateSet(this, _start, performance.now() - updatedValue);
|
|
1198
|
-
}
|
|
1199
|
-
};
|
|
1200
1099
|
function getDefaultExportFromCjs(x) {
|
|
1201
1100
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
1202
1101
|
}
|
|
@@ -1439,7 +1338,7 @@ function requireTimsort$1() {
|
|
|
1439
1338
|
}
|
|
1440
1339
|
return offset;
|
|
1441
1340
|
}
|
|
1442
|
-
var TimSort = function() {
|
|
1341
|
+
var TimSort = (function() {
|
|
1443
1342
|
function TimSort2(array, compare) {
|
|
1444
1343
|
_classCallCheck(this, TimSort2);
|
|
1445
1344
|
this.array = null;
|
|
@@ -1767,7 +1666,7 @@ function requireTimsort$1() {
|
|
|
1767
1666
|
}
|
|
1768
1667
|
};
|
|
1769
1668
|
return TimSort2;
|
|
1770
|
-
}();
|
|
1669
|
+
})();
|
|
1771
1670
|
function sort(array, compare, lo, hi) {
|
|
1772
1671
|
if (!Array.isArray(array)) {
|
|
1773
1672
|
throw new TypeError("Can only sort arrays");
|
|
@@ -1888,69 +1787,57 @@ function requireLib() {
|
|
|
1888
1787
|
var libExports = requireLib();
|
|
1889
1788
|
const percentile = /* @__PURE__ */ getDefaultExportFromCjs(libExports);
|
|
1890
1789
|
class InstrumentGaugeOptions extends InstrumentBaseOptions {
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
__publicField(this, "fromJSON");
|
|
1896
|
-
__publicField(this, "initValue");
|
|
1897
|
-
}
|
|
1790
|
+
interval;
|
|
1791
|
+
sampleSize;
|
|
1792
|
+
fromJSON;
|
|
1793
|
+
initValue;
|
|
1898
1794
|
}
|
|
1899
1795
|
class InstrumentGaugeTelemetry extends InstrumentBaseTelemetry {
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
__publicField(this, "Inc");
|
|
1904
|
-
__publicField(this, "Dec");
|
|
1905
|
-
}
|
|
1796
|
+
val;
|
|
1797
|
+
Inc;
|
|
1798
|
+
Dec;
|
|
1906
1799
|
}
|
|
1907
1800
|
class InstrumentGauge extends InstrumentBase {
|
|
1801
|
+
#val = 0;
|
|
1802
|
+
#maxval = null;
|
|
1803
|
+
#lastObservedValue = 0;
|
|
1804
|
+
#timeSeriesList = [];
|
|
1805
|
+
#maxSampleSize = 0;
|
|
1806
|
+
#timerInterval = 0;
|
|
1807
|
+
#observer = null;
|
|
1808
|
+
//@@ extras
|
|
1809
|
+
#min = null;
|
|
1810
|
+
#max = 0;
|
|
1811
|
+
#observations = 0;
|
|
1812
|
+
#total = 0;
|
|
1813
|
+
#copy = false;
|
|
1908
1814
|
constructor(options = {}) {
|
|
1909
1815
|
super(options);
|
|
1910
|
-
__privateAdd(this, _InstrumentGauge_instances);
|
|
1911
|
-
__privateAdd(this, _val3, 0);
|
|
1912
|
-
__privateAdd(this, _maxval, null);
|
|
1913
|
-
__privateAdd(this, _lastObservedValue, 0);
|
|
1914
|
-
__privateAdd(this, _timeSeriesList, []);
|
|
1915
|
-
__privateAdd(this, _maxSampleSize, 0);
|
|
1916
|
-
__privateAdd(this, _timerInterval2, 0);
|
|
1917
|
-
__privateAdd(this, _observer, null);
|
|
1918
|
-
//@@ extras
|
|
1919
|
-
__privateAdd(this, _min, null);
|
|
1920
|
-
__privateAdd(this, _max, 0);
|
|
1921
|
-
__privateAdd(this, _observations, 0);
|
|
1922
|
-
__privateAdd(this, _total, 0);
|
|
1923
|
-
__privateAdd(this, _copy5, false);
|
|
1924
|
-
__publicField(this, "percentile");
|
|
1925
|
-
__publicField(this, "min");
|
|
1926
|
-
__publicField(this, "max");
|
|
1927
|
-
__publicField(this, "avg");
|
|
1928
|
-
__publicField(this, "val", 0);
|
|
1929
1816
|
if (!options.label) {
|
|
1930
1817
|
this.label = "InstrumentGauge";
|
|
1931
1818
|
} else {
|
|
1932
1819
|
this.label = options.label;
|
|
1933
1820
|
}
|
|
1934
1821
|
if (typeof options.interval === "undefined") {
|
|
1935
|
-
|
|
1822
|
+
this.#timerInterval = 0;
|
|
1936
1823
|
} else {
|
|
1937
|
-
|
|
1824
|
+
this.#timerInterval = options.interval;
|
|
1938
1825
|
}
|
|
1939
1826
|
if (typeof options.sampleSize === "undefined") {
|
|
1940
|
-
|
|
1827
|
+
this.#maxSampleSize = 600;
|
|
1941
1828
|
} else {
|
|
1942
|
-
|
|
1829
|
+
this.#maxSampleSize = options.sampleSize;
|
|
1943
1830
|
}
|
|
1944
1831
|
if (typeof options.fromJSON === "undefined") {
|
|
1945
|
-
|
|
1832
|
+
this.#copy = false;
|
|
1946
1833
|
} else {
|
|
1947
|
-
|
|
1834
|
+
this.#copy = true;
|
|
1948
1835
|
}
|
|
1949
1836
|
Object.defineProperty(this, GaugeTypes.GAUGE_TYPE, {
|
|
1950
1837
|
enumerable: true,
|
|
1951
1838
|
get: () => GaugeTypes.INSTRUMENT_GAUGE
|
|
1952
1839
|
});
|
|
1953
|
-
if (
|
|
1840
|
+
if (this.#copy) {
|
|
1954
1841
|
this.DefineCopyProperties([
|
|
1955
1842
|
"val",
|
|
1956
1843
|
"min",
|
|
@@ -1961,15 +1848,15 @@ class InstrumentGauge extends InstrumentBase {
|
|
|
1961
1848
|
} else {
|
|
1962
1849
|
Object.defineProperty(this, "val", {
|
|
1963
1850
|
enumerable: true,
|
|
1964
|
-
get: () =>
|
|
1851
|
+
get: () => this.#GetVal(),
|
|
1965
1852
|
set: (value) => {
|
|
1966
|
-
|
|
1853
|
+
this.#SetVal(value);
|
|
1967
1854
|
}
|
|
1968
1855
|
});
|
|
1969
|
-
if (
|
|
1856
|
+
if (this.#timerInterval > 0) {
|
|
1970
1857
|
Object.defineProperty(this, "percentile", {
|
|
1971
1858
|
enumerable: true,
|
|
1972
|
-
get: () =>
|
|
1859
|
+
get: () => this.#GetPercentileData()
|
|
1973
1860
|
});
|
|
1974
1861
|
this._StartTimer();
|
|
1975
1862
|
}
|
|
@@ -1994,6 +1881,11 @@ class InstrumentGauge extends InstrumentBase {
|
|
|
1994
1881
|
}
|
|
1995
1882
|
}
|
|
1996
1883
|
}
|
|
1884
|
+
percentile;
|
|
1885
|
+
min;
|
|
1886
|
+
max;
|
|
1887
|
+
avg;
|
|
1888
|
+
val = 0;
|
|
1997
1889
|
WithInitVal(initVal) {
|
|
1998
1890
|
this.val = initVal;
|
|
1999
1891
|
return this;
|
|
@@ -2001,66 +1893,134 @@ class InstrumentGauge extends InstrumentBase {
|
|
|
2001
1893
|
WithMin() {
|
|
2002
1894
|
Object.defineProperty(this, "min", {
|
|
2003
1895
|
enumerable: true,
|
|
2004
|
-
get: () =>
|
|
1896
|
+
get: () => this.#GetMin()
|
|
2005
1897
|
});
|
|
2006
1898
|
return this;
|
|
2007
1899
|
}
|
|
2008
1900
|
WithMax() {
|
|
2009
1901
|
Object.defineProperty(this, "max", {
|
|
2010
1902
|
enumerable: true,
|
|
2011
|
-
get: () =>
|
|
1903
|
+
get: () => this.#GetMax()
|
|
2012
1904
|
});
|
|
2013
1905
|
return this;
|
|
2014
1906
|
}
|
|
2015
1907
|
WithAverage() {
|
|
2016
1908
|
Object.defineProperty(this, "avg", {
|
|
2017
1909
|
enumerable: true,
|
|
2018
|
-
get: () =>
|
|
1910
|
+
get: () => this.#GetAverage()
|
|
2019
1911
|
});
|
|
2020
1912
|
return this;
|
|
2021
1913
|
}
|
|
2022
1914
|
_StartTimer() {
|
|
2023
|
-
if (
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
if (
|
|
2027
|
-
|
|
1915
|
+
if (this.#timerInterval > 0) {
|
|
1916
|
+
this.#timeSeriesList = [];
|
|
1917
|
+
this.#observer = setInterval(() => {
|
|
1918
|
+
if (this.#timeSeriesList.length > this.#maxSampleSize) {
|
|
1919
|
+
this.#timeSeriesList.shift();
|
|
2028
1920
|
}
|
|
2029
|
-
const maxval =
|
|
2030
|
-
|
|
2031
|
-
},
|
|
1921
|
+
const maxval = this.#GetAndResetMaxVal();
|
|
1922
|
+
this.#timeSeriesList.push(maxval);
|
|
1923
|
+
}, this.#timerInterval);
|
|
2032
1924
|
if (isNode) {
|
|
2033
|
-
|
|
1925
|
+
this.#observer.unref();
|
|
2034
1926
|
}
|
|
2035
1927
|
} else {
|
|
2036
1928
|
throw new Error(`Unable to StartTimer for this instrument. The interval is set to <= 0.`);
|
|
2037
1929
|
}
|
|
2038
1930
|
}
|
|
2039
1931
|
StopTimer() {
|
|
2040
|
-
if (
|
|
2041
|
-
clearTimeout(
|
|
2042
|
-
|
|
2043
|
-
|
|
1932
|
+
if (this.#observer) {
|
|
1933
|
+
clearTimeout(this.#observer);
|
|
1934
|
+
this.#observer = null;
|
|
1935
|
+
this.#timeSeriesList = [];
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
/**
|
|
1939
|
+
* If the gauge is being monitored as part of a time series, get the most recent recorded value (max value) from within the time interval
|
|
1940
|
+
* otherwise, just return the current instant value.
|
|
1941
|
+
*/
|
|
1942
|
+
#GetVal() {
|
|
1943
|
+
if (this.#timerInterval > 0 && this.#observer !== null) {
|
|
1944
|
+
if (this.#maxval === null) {
|
|
1945
|
+
return this.GetNumber(this.#lastObservedValue);
|
|
1946
|
+
} else {
|
|
1947
|
+
return this.GetNumber(this.#maxval);
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
return this.GetNumber(this.#val);
|
|
1951
|
+
}
|
|
1952
|
+
#SetVal(updatedValue) {
|
|
1953
|
+
this.#val = updatedValue;
|
|
1954
|
+
this.#observations++;
|
|
1955
|
+
this.#total += updatedValue;
|
|
1956
|
+
if (this.#val > this.#max) {
|
|
1957
|
+
this.#max = this.#val;
|
|
1958
|
+
}
|
|
1959
|
+
if (this.#min !== null) {
|
|
1960
|
+
if (this.#val < this.#min) {
|
|
1961
|
+
this.#min = this.#val;
|
|
1962
|
+
}
|
|
1963
|
+
} else {
|
|
1964
|
+
this.#min = this.#val;
|
|
1965
|
+
}
|
|
1966
|
+
if (this.#timerInterval > 0) {
|
|
1967
|
+
this.#lastObservedValue = updatedValue;
|
|
1968
|
+
if (this.#maxval === null) {
|
|
1969
|
+
this.#maxval = this.#val;
|
|
1970
|
+
} else if (this.#val > this.#maxval) {
|
|
1971
|
+
this.#maxval = this.#val;
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
#GetMin() {
|
|
1976
|
+
if (this.#min !== null) {
|
|
1977
|
+
return this.#min;
|
|
2044
1978
|
}
|
|
1979
|
+
return 0;
|
|
1980
|
+
}
|
|
1981
|
+
#GetMax() {
|
|
1982
|
+
return this.#max;
|
|
1983
|
+
}
|
|
1984
|
+
#GetAverage() {
|
|
1985
|
+
if (this.#observations > 0) {
|
|
1986
|
+
return this.#total / this.#observations;
|
|
1987
|
+
}
|
|
1988
|
+
return 0;
|
|
2045
1989
|
}
|
|
2046
1990
|
Reset() {
|
|
2047
1991
|
this.StopTimer();
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
if (
|
|
1992
|
+
this.#maxval = 0;
|
|
1993
|
+
this.#lastObservedValue = 0;
|
|
1994
|
+
this.#val = 0;
|
|
1995
|
+
this.#min = null;
|
|
1996
|
+
this.#max = 0;
|
|
1997
|
+
this.#observations = 0;
|
|
1998
|
+
this.#total = 0;
|
|
1999
|
+
if (this.#timerInterval > 0) {
|
|
2056
2000
|
this._StartTimer();
|
|
2057
2001
|
}
|
|
2058
2002
|
}
|
|
2003
|
+
#GetAndResetMaxVal() {
|
|
2004
|
+
if (this.#maxval === null) {
|
|
2005
|
+
return this.#lastObservedValue;
|
|
2006
|
+
}
|
|
2007
|
+
const retVal = this.#maxval;
|
|
2008
|
+
this.#maxval = null;
|
|
2009
|
+
return retVal;
|
|
2010
|
+
}
|
|
2059
2011
|
Inc(incVal = 1) {
|
|
2060
|
-
|
|
2012
|
+
this.#SetVal(this.#val + incVal);
|
|
2061
2013
|
}
|
|
2062
2014
|
Dec(decVal = 1) {
|
|
2063
|
-
|
|
2015
|
+
this.#SetVal(this.#val - decVal);
|
|
2016
|
+
}
|
|
2017
|
+
#NumberCompare(a, b) {
|
|
2018
|
+
return a - b;
|
|
2019
|
+
}
|
|
2020
|
+
#GetPercentileData() {
|
|
2021
|
+
const sortedList = this.#timeSeriesList.slice(0);
|
|
2022
|
+
timsortExports.sort(sortedList, this.#NumberCompare);
|
|
2023
|
+
return percentile([50, 80, 90, 95, 99, 99.95], sortedList);
|
|
2064
2024
|
}
|
|
2065
2025
|
ProcessTelemetry(telemetry) {
|
|
2066
2026
|
if (telemetry.Inc !== void 0) {
|
|
@@ -2074,131 +2034,42 @@ class InstrumentGauge extends InstrumentBase {
|
|
|
2074
2034
|
}
|
|
2075
2035
|
}
|
|
2076
2036
|
}
|
|
2077
|
-
_val3 = new WeakMap();
|
|
2078
|
-
_maxval = new WeakMap();
|
|
2079
|
-
_lastObservedValue = new WeakMap();
|
|
2080
|
-
_timeSeriesList = new WeakMap();
|
|
2081
|
-
_maxSampleSize = new WeakMap();
|
|
2082
|
-
_timerInterval2 = new WeakMap();
|
|
2083
|
-
_observer = new WeakMap();
|
|
2084
|
-
_min = new WeakMap();
|
|
2085
|
-
_max = new WeakMap();
|
|
2086
|
-
_observations = new WeakMap();
|
|
2087
|
-
_total = new WeakMap();
|
|
2088
|
-
_copy5 = new WeakMap();
|
|
2089
|
-
_InstrumentGauge_instances = new WeakSet();
|
|
2090
|
-
/**
|
|
2091
|
-
* If the gauge is being monitored as part of a time series, get the most recent recorded value (max value) from within the time interval
|
|
2092
|
-
* otherwise, just return the current instant value.
|
|
2093
|
-
*/
|
|
2094
|
-
GetVal_fn5 = function() {
|
|
2095
|
-
if (__privateGet(this, _timerInterval2) > 0 && __privateGet(this, _observer) !== null) {
|
|
2096
|
-
if (__privateGet(this, _maxval) === null) {
|
|
2097
|
-
return this.GetNumber(__privateGet(this, _lastObservedValue));
|
|
2098
|
-
} else {
|
|
2099
|
-
return this.GetNumber(__privateGet(this, _maxval));
|
|
2100
|
-
}
|
|
2101
|
-
}
|
|
2102
|
-
return this.GetNumber(__privateGet(this, _val3));
|
|
2103
|
-
};
|
|
2104
|
-
SetVal_fn5 = function(updatedValue) {
|
|
2105
|
-
__privateSet(this, _val3, updatedValue);
|
|
2106
|
-
__privateWrapper(this, _observations)._++;
|
|
2107
|
-
__privateSet(this, _total, __privateGet(this, _total) + updatedValue);
|
|
2108
|
-
if (__privateGet(this, _val3) > __privateGet(this, _max)) {
|
|
2109
|
-
__privateSet(this, _max, __privateGet(this, _val3));
|
|
2110
|
-
}
|
|
2111
|
-
if (__privateGet(this, _min) !== null) {
|
|
2112
|
-
if (__privateGet(this, _val3) < __privateGet(this, _min)) {
|
|
2113
|
-
__privateSet(this, _min, __privateGet(this, _val3));
|
|
2114
|
-
}
|
|
2115
|
-
} else {
|
|
2116
|
-
__privateSet(this, _min, __privateGet(this, _val3));
|
|
2117
|
-
}
|
|
2118
|
-
if (__privateGet(this, _timerInterval2) > 0) {
|
|
2119
|
-
__privateSet(this, _lastObservedValue, updatedValue);
|
|
2120
|
-
if (__privateGet(this, _maxval) === null) {
|
|
2121
|
-
__privateSet(this, _maxval, __privateGet(this, _val3));
|
|
2122
|
-
} else if (__privateGet(this, _val3) > __privateGet(this, _maxval)) {
|
|
2123
|
-
__privateSet(this, _maxval, __privateGet(this, _val3));
|
|
2124
|
-
}
|
|
2125
|
-
}
|
|
2126
|
-
};
|
|
2127
|
-
GetMin_fn = function() {
|
|
2128
|
-
if (__privateGet(this, _min) !== null) {
|
|
2129
|
-
return __privateGet(this, _min);
|
|
2130
|
-
}
|
|
2131
|
-
return 0;
|
|
2132
|
-
};
|
|
2133
|
-
GetMax_fn = function() {
|
|
2134
|
-
return __privateGet(this, _max);
|
|
2135
|
-
};
|
|
2136
|
-
GetAverage_fn = function() {
|
|
2137
|
-
if (__privateGet(this, _observations) > 0) {
|
|
2138
|
-
return __privateGet(this, _total) / __privateGet(this, _observations);
|
|
2139
|
-
}
|
|
2140
|
-
return 0;
|
|
2141
|
-
};
|
|
2142
|
-
GetAndResetMaxVal_fn = function() {
|
|
2143
|
-
if (__privateGet(this, _maxval) === null) {
|
|
2144
|
-
return __privateGet(this, _lastObservedValue);
|
|
2145
|
-
}
|
|
2146
|
-
const retVal = __privateGet(this, _maxval);
|
|
2147
|
-
__privateSet(this, _maxval, null);
|
|
2148
|
-
return retVal;
|
|
2149
|
-
};
|
|
2150
|
-
NumberCompare_fn = function(a, b) {
|
|
2151
|
-
return a - b;
|
|
2152
|
-
};
|
|
2153
|
-
GetPercentileData_fn = function() {
|
|
2154
|
-
const sortedList = __privateGet(this, _timeSeriesList).slice(0);
|
|
2155
|
-
timsortExports.sort(sortedList, __privateMethod(this, _InstrumentGauge_instances, NumberCompare_fn));
|
|
2156
|
-
return percentile([50, 80, 90, 95, 99, 99.95], sortedList);
|
|
2157
|
-
};
|
|
2158
2037
|
class InstrumentObjectOptions extends InstrumentBaseOptions {
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
__publicField(this, "fromJSON");
|
|
2162
|
-
__publicField(this, "initValue");
|
|
2163
|
-
}
|
|
2038
|
+
fromJSON;
|
|
2039
|
+
initValue;
|
|
2164
2040
|
}
|
|
2165
2041
|
class InstrumentObjectTelemetry extends InstrumentBaseTelemetry {
|
|
2166
|
-
|
|
2167
|
-
super(...arguments);
|
|
2168
|
-
__publicField(this, "val");
|
|
2169
|
-
}
|
|
2042
|
+
val;
|
|
2170
2043
|
}
|
|
2171
2044
|
class InstrumentObject extends InstrumentBase {
|
|
2045
|
+
#val = {};
|
|
2046
|
+
#copy = false;
|
|
2172
2047
|
constructor(options = {}) {
|
|
2173
2048
|
super(options);
|
|
2174
|
-
__privateAdd(this, _InstrumentObject_instances);
|
|
2175
|
-
__privateAdd(this, _val4, {});
|
|
2176
|
-
__privateAdd(this, _copy6, false);
|
|
2177
|
-
__publicField(this, "val");
|
|
2178
2049
|
if (typeof options.label === "undefined") {
|
|
2179
2050
|
this.label = "InstrumentObject";
|
|
2180
2051
|
} else {
|
|
2181
2052
|
this.label = options.label;
|
|
2182
2053
|
}
|
|
2183
2054
|
if (typeof options.fromJSON === "undefined") {
|
|
2184
|
-
|
|
2055
|
+
this.#copy = false;
|
|
2185
2056
|
} else {
|
|
2186
|
-
|
|
2057
|
+
this.#copy = true;
|
|
2187
2058
|
}
|
|
2188
2059
|
Object.defineProperty(this, GaugeTypes.GAUGE_TYPE, {
|
|
2189
2060
|
enumerable: true,
|
|
2190
2061
|
get: () => GaugeTypes.INSTRUMENT_OBJECT
|
|
2191
2062
|
});
|
|
2192
|
-
if (
|
|
2063
|
+
if (this.#copy) {
|
|
2193
2064
|
this.DefineCopyProperties([
|
|
2194
2065
|
"val"
|
|
2195
2066
|
]);
|
|
2196
2067
|
} else {
|
|
2197
2068
|
Object.defineProperty(this, "val", {
|
|
2198
2069
|
enumerable: true,
|
|
2199
|
-
get: () =>
|
|
2070
|
+
get: () => this.#GetVal(),
|
|
2200
2071
|
set: (value) => {
|
|
2201
|
-
|
|
2072
|
+
this.#SetVal(value);
|
|
2202
2073
|
}
|
|
2203
2074
|
});
|
|
2204
2075
|
}
|
|
@@ -2212,25 +2083,23 @@ class InstrumentObject extends InstrumentBase {
|
|
|
2212
2083
|
this.val = result.val;
|
|
2213
2084
|
}
|
|
2214
2085
|
}
|
|
2086
|
+
val;
|
|
2215
2087
|
WithInitVal(initVal) {
|
|
2216
2088
|
this.val = initVal;
|
|
2217
2089
|
return this;
|
|
2218
2090
|
}
|
|
2091
|
+
#GetVal() {
|
|
2092
|
+
return this.#val;
|
|
2093
|
+
}
|
|
2094
|
+
#SetVal(updatedValue) {
|
|
2095
|
+
this.#val = updatedValue;
|
|
2096
|
+
}
|
|
2219
2097
|
ProcessTelemetry(telemetry) {
|
|
2220
2098
|
if (telemetry.val !== void 0) {
|
|
2221
2099
|
this.val = telemetry.val;
|
|
2222
2100
|
}
|
|
2223
2101
|
}
|
|
2224
2102
|
}
|
|
2225
|
-
_val4 = new WeakMap();
|
|
2226
|
-
_copy6 = new WeakMap();
|
|
2227
|
-
_InstrumentObject_instances = new WeakSet();
|
|
2228
|
-
GetVal_fn6 = function() {
|
|
2229
|
-
return __privateGet(this, _val4);
|
|
2230
|
-
};
|
|
2231
|
-
SetVal_fn6 = function(updatedValue) {
|
|
2232
|
-
__privateSet(this, _val4, updatedValue);
|
|
2233
|
-
};
|
|
2234
2103
|
function CreateInstrument(sourceInstrument) {
|
|
2235
2104
|
switch (sourceInstrument[GaugeTypes.GAUGE_TYPE]) {
|
|
2236
2105
|
case GaugeTypes.INSTRUMENT_GAUGE:
|
|
@@ -2428,71 +2297,69 @@ var RequestLoggerMiddlewareEventName = /* @__PURE__ */ ((RequestLoggerMiddleware
|
|
|
2428
2297
|
return RequestLoggerMiddlewareEventName2;
|
|
2429
2298
|
})(RequestLoggerMiddlewareEventName || {});
|
|
2430
2299
|
class RequestLoggerMiddleware extends STSOptionsBase {
|
|
2300
|
+
#tinyEmitter = new TinyEmitter();
|
|
2431
2301
|
constructor(options) {
|
|
2432
2302
|
super(options);
|
|
2433
|
-
__privateAdd(this, _tinyEmitter, new TinyEmitter());
|
|
2434
|
-
__privateAdd(this, _RequestCompleted, (start) => {
|
|
2435
|
-
__privateGet(this, _tinyEmitter).emit(
|
|
2436
|
-
"UpdateInstrument_AR_DEC"
|
|
2437
|
-
/* UpdateInstrument_AR_DEC */
|
|
2438
|
-
);
|
|
2439
|
-
let timeInMs = 0;
|
|
2440
|
-
const end = process.hrtime(start);
|
|
2441
|
-
timeInMs = (end[0] * 1e9 + end[1]) / 1e6;
|
|
2442
|
-
timeInMs = parseFloat(timeInMs.toFixed(4));
|
|
2443
|
-
__privateGet(this, _tinyEmitter).emit("UpdateInstrument_DH_VAL", timeInMs);
|
|
2444
|
-
__privateGet(this, _tinyEmitter).emit("UpdateInstrument_D_VAL", timeInMs);
|
|
2445
|
-
});
|
|
2446
|
-
// https://stackoverflow.com/questions/18031839/how-to-use-process-hrtime-to-get-execution-time-of-async-function/18031945
|
|
2447
|
-
/**
|
|
2448
|
-
* Use with .bind(class instance).
|
|
2449
|
-
* Example;
|
|
2450
|
-
* ---
|
|
2451
|
-
* `let requestLoggerMiddleware = new RequestLoggerMiddleware();
|
|
2452
|
-
* app.use(requestLoggerMiddleware.Middleware.bind(requestLoggerMiddleware));`
|
|
2453
|
-
* @param {*} req
|
|
2454
|
-
* @param {*} res
|
|
2455
|
-
* @param {*} next
|
|
2456
|
-
* @returns
|
|
2457
|
-
*/
|
|
2458
|
-
__publicField(this, "Middleware", async (req, res, next) => {
|
|
2459
|
-
if (this.options.ignoresocketio && req.originalUrl.includes("socket.io")) {
|
|
2460
|
-
return;
|
|
2461
|
-
}
|
|
2462
|
-
const start = process.hrtime();
|
|
2463
|
-
__privateGet(this, _tinyEmitter).emit(
|
|
2464
|
-
"UpdateInstrument_AR_INC"
|
|
2465
|
-
/* UpdateInstrument_AR_INC */
|
|
2466
|
-
);
|
|
2467
|
-
__privateGet(this, _tinyEmitter).emit(
|
|
2468
|
-
"UpdateInstrument_RC_INC"
|
|
2469
|
-
/* UpdateInstrument_RC_INC */
|
|
2470
|
-
);
|
|
2471
|
-
__privateGet(this, _tinyEmitter).emit(
|
|
2472
|
-
"UpdateInstrument_V_INC"
|
|
2473
|
-
/* UpdateInstrument_V_INC */
|
|
2474
|
-
);
|
|
2475
|
-
req.on("aborted", () => {
|
|
2476
|
-
});
|
|
2477
|
-
req.on("close", () => {
|
|
2478
|
-
__privateGet(this, _RequestCompleted).call(this, start);
|
|
2479
|
-
});
|
|
2480
|
-
req.on("end", () => {
|
|
2481
|
-
});
|
|
2482
|
-
res.on("finish", () => {
|
|
2483
|
-
});
|
|
2484
|
-
next();
|
|
2485
|
-
});
|
|
2486
2303
|
}
|
|
2487
2304
|
get options() {
|
|
2488
2305
|
return super.options;
|
|
2489
2306
|
}
|
|
2490
2307
|
on(eventName, callBackFn) {
|
|
2491
|
-
|
|
2492
|
-
}
|
|
2308
|
+
this.#tinyEmitter.on(eventName, callBackFn);
|
|
2309
|
+
}
|
|
2310
|
+
#RequestCompleted = (start) => {
|
|
2311
|
+
this.#tinyEmitter.emit(
|
|
2312
|
+
"UpdateInstrument_AR_DEC"
|
|
2313
|
+
/* UpdateInstrument_AR_DEC */
|
|
2314
|
+
);
|
|
2315
|
+
let timeInMs = 0;
|
|
2316
|
+
const end = process.hrtime(start);
|
|
2317
|
+
timeInMs = (end[0] * 1e9 + end[1]) / 1e6;
|
|
2318
|
+
timeInMs = parseFloat(timeInMs.toFixed(4));
|
|
2319
|
+
this.#tinyEmitter.emit("UpdateInstrument_DH_VAL", timeInMs);
|
|
2320
|
+
this.#tinyEmitter.emit("UpdateInstrument_D_VAL", timeInMs);
|
|
2321
|
+
};
|
|
2322
|
+
// https://stackoverflow.com/questions/18031839/how-to-use-process-hrtime-to-get-execution-time-of-async-function/18031945
|
|
2323
|
+
/**
|
|
2324
|
+
* Use with .bind(class instance).
|
|
2325
|
+
* Example;
|
|
2326
|
+
* ---
|
|
2327
|
+
* `let requestLoggerMiddleware = new RequestLoggerMiddleware();
|
|
2328
|
+
* app.use(requestLoggerMiddleware.Middleware.bind(requestLoggerMiddleware));`
|
|
2329
|
+
* @param {*} req
|
|
2330
|
+
* @param {*} res
|
|
2331
|
+
* @param {*} next
|
|
2332
|
+
* @returns
|
|
2333
|
+
*/
|
|
2334
|
+
Middleware = async (req, res, next) => {
|
|
2335
|
+
if (this.options.ignoresocketio && req.originalUrl.includes("socket.io")) {
|
|
2336
|
+
return;
|
|
2337
|
+
}
|
|
2338
|
+
const start = process.hrtime();
|
|
2339
|
+
this.#tinyEmitter.emit(
|
|
2340
|
+
"UpdateInstrument_AR_INC"
|
|
2341
|
+
/* UpdateInstrument_AR_INC */
|
|
2342
|
+
);
|
|
2343
|
+
this.#tinyEmitter.emit(
|
|
2344
|
+
"UpdateInstrument_RC_INC"
|
|
2345
|
+
/* UpdateInstrument_RC_INC */
|
|
2346
|
+
);
|
|
2347
|
+
this.#tinyEmitter.emit(
|
|
2348
|
+
"UpdateInstrument_V_INC"
|
|
2349
|
+
/* UpdateInstrument_V_INC */
|
|
2350
|
+
);
|
|
2351
|
+
req.on("aborted", () => {
|
|
2352
|
+
});
|
|
2353
|
+
req.on("close", () => {
|
|
2354
|
+
this.#RequestCompleted(start);
|
|
2355
|
+
});
|
|
2356
|
+
req.on("end", () => {
|
|
2357
|
+
});
|
|
2358
|
+
res.on("finish", () => {
|
|
2359
|
+
});
|
|
2360
|
+
next();
|
|
2361
|
+
};
|
|
2493
2362
|
}
|
|
2494
|
-
_tinyEmitter = new WeakMap();
|
|
2495
|
-
_RequestCompleted = new WeakMap();
|
|
2496
2363
|
var ansiStyles = { exports: {} };
|
|
2497
2364
|
var colorName;
|
|
2498
2365
|
var hasRequiredColorName;
|
|
@@ -4206,15 +4073,15 @@ const DEFAULT_INITIAL_BUFFER_SIZE = 2048;
|
|
|
4206
4073
|
class Encoder {
|
|
4207
4074
|
constructor(options) {
|
|
4208
4075
|
this.entered = false;
|
|
4209
|
-
this.extensionCodec =
|
|
4210
|
-
this.context = options
|
|
4211
|
-
this.useBigInt64 =
|
|
4212
|
-
this.maxDepth =
|
|
4213
|
-
this.initialBufferSize =
|
|
4214
|
-
this.sortKeys =
|
|
4215
|
-
this.forceFloat32 =
|
|
4216
|
-
this.ignoreUndefined =
|
|
4217
|
-
this.forceIntegerToFloat =
|
|
4076
|
+
this.extensionCodec = options?.extensionCodec ?? ExtensionCodec.defaultCodec;
|
|
4077
|
+
this.context = options?.context;
|
|
4078
|
+
this.useBigInt64 = options?.useBigInt64 ?? false;
|
|
4079
|
+
this.maxDepth = options?.maxDepth ?? DEFAULT_MAX_DEPTH;
|
|
4080
|
+
this.initialBufferSize = options?.initialBufferSize ?? DEFAULT_INITIAL_BUFFER_SIZE;
|
|
4081
|
+
this.sortKeys = options?.sortKeys ?? false;
|
|
4082
|
+
this.forceFloat32 = options?.forceFloat32 ?? false;
|
|
4083
|
+
this.ignoreUndefined = options?.ignoreUndefined ?? false;
|
|
4084
|
+
this.forceIntegerToFloat = options?.forceIntegerToFloat ?? false;
|
|
4218
4085
|
this.pos = 0;
|
|
4219
4086
|
this.view = new DataView(new ArrayBuffer(this.initialBufferSize));
|
|
4220
4087
|
this.bytes = new Uint8Array(this.view.buffer);
|
|
@@ -4597,58 +4464,58 @@ function encode(value, options) {
|
|
|
4597
4464
|
class PublishTransportRESTServer extends STSOptionsBase {
|
|
4598
4465
|
constructor(options) {
|
|
4599
4466
|
super(options);
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4467
|
+
}
|
|
4468
|
+
get options() {
|
|
4469
|
+
return super.options;
|
|
4470
|
+
}
|
|
4471
|
+
// Returns true for success or false for failure.
|
|
4472
|
+
Publish = async (payload) => {
|
|
4473
|
+
try {
|
|
4474
|
+
if (this.options.showPublishPayload) {
|
|
4475
|
+
console.log(chalk.grey(`PublishTransportRESTServer::Publish() url: [${this.options.url}]`));
|
|
4476
|
+
console.log(payload);
|
|
4477
|
+
}
|
|
4478
|
+
const encodedData = encode(payload, { ignoreUndefined: true });
|
|
4479
|
+
const headers = { "Content-Type": "application/octet-stream" };
|
|
4480
|
+
let retVal = null;
|
|
4481
|
+
if (this.options.socketPath) {
|
|
4482
|
+
retVal = await axios({
|
|
4483
|
+
method: "post",
|
|
4484
|
+
data: Buffer.from(encodedData),
|
|
4485
|
+
headers,
|
|
4486
|
+
socketPath: this.options.socketPath
|
|
4487
|
+
});
|
|
4488
|
+
} else {
|
|
4489
|
+
if (isNode) {
|
|
4490
|
+
if (this.options.agentManager) {
|
|
4491
|
+
retVal = await axios(new STSAxiosConfig(this.options.url, "post", headers).withData(Buffer.from(encodedData)).withAgentManager(this.options.agentManager).config);
|
|
4624
4492
|
} else {
|
|
4625
|
-
|
|
4626
|
-
retVal = await axios(new STSAxiosConfig(this.options.url, "post", headers).withData(blob).config);
|
|
4627
|
-
}
|
|
4628
|
-
}
|
|
4629
|
-
if (retVal.status !== 200) {
|
|
4630
|
-
if (this.options.showPublishPayload) {
|
|
4631
|
-
console.log(chalk.red(`PublishTransportRESTServer::Publish() Error (_PerformPublishRESTAPI:_PerformPublish:#publishmessage): Invalid response from server: [${retVal.status}]`));
|
|
4493
|
+
retVal = await axios(new STSAxiosConfig(this.options.url, "post", headers).withData(Buffer.from(encodedData)).config);
|
|
4632
4494
|
}
|
|
4633
|
-
this.options.logger.debug(chalk.red(`Error (_PerformPublishRESTAPI:_PerformPublish:#publishmessage): Invalid response from server: [${retVal.status}]`));
|
|
4634
|
-
return false;
|
|
4635
4495
|
} else {
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
}
|
|
4496
|
+
const blob = new Blob([new Uint8Array(encodedData)], { type: "application/octet-stream" });
|
|
4497
|
+
retVal = await axios(new STSAxiosConfig(this.options.url, "post", headers).withData(blob).config);
|
|
4639
4498
|
}
|
|
4640
|
-
|
|
4641
|
-
|
|
4499
|
+
}
|
|
4500
|
+
if (retVal.status !== 200) {
|
|
4642
4501
|
if (this.options.showPublishPayload) {
|
|
4643
|
-
console.log(chalk.red(`PublishTransportRESTServer::Publish() Error (
|
|
4502
|
+
console.log(chalk.red(`PublishTransportRESTServer::Publish() Error (_PerformPublishRESTAPI:_PerformPublish:#publishmessage): Invalid response from server: [${retVal.status}]`));
|
|
4644
4503
|
}
|
|
4504
|
+
this.options.logger.debug(chalk.red(`Error (_PerformPublishRESTAPI:_PerformPublish:#publishmessage): Invalid response from server: [${retVal.status}]`));
|
|
4645
4505
|
return false;
|
|
4506
|
+
} else {
|
|
4507
|
+
if (this.options.showPublishPayload) {
|
|
4508
|
+
console.log(chalk.grey(`PublishTransportRESTServer::Publish() _PerformPublishRESTAPI:_PerformPublish:#publishmessage: [${this.options.url}] - Valid response from server: [${retVal.status}]`));
|
|
4509
|
+
}
|
|
4646
4510
|
}
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4511
|
+
return true;
|
|
4512
|
+
} catch (error) {
|
|
4513
|
+
if (this.options.showPublishPayload) {
|
|
4514
|
+
console.log(chalk.red(`PublishTransportRESTServer::Publish() Error (PublishRESTServer:_PerformPublishRESTAPI:Error: [${error}]`));
|
|
4515
|
+
}
|
|
4516
|
+
return false;
|
|
4517
|
+
}
|
|
4518
|
+
};
|
|
4652
4519
|
async Close() {
|
|
4653
4520
|
if (this.options.agentManager) {
|
|
4654
4521
|
this.options.agentManager.Terminate();
|
|
@@ -4657,115 +4524,103 @@ class PublishTransportRESTServer extends STSOptionsBase {
|
|
|
4657
4524
|
}
|
|
4658
4525
|
}
|
|
4659
4526
|
class PublishInstruments extends STSOptionsBase {
|
|
4527
|
+
#inPublish = false;
|
|
4528
|
+
#observer = null;
|
|
4529
|
+
#publishState = 0;
|
|
4530
|
+
#publisherTransport = null;
|
|
4660
4531
|
constructor(options) {
|
|
4661
4532
|
super(options);
|
|
4662
|
-
|
|
4663
|
-
__privateAdd(this, _inPublish, false);
|
|
4664
|
-
__privateAdd(this, _observer2, null);
|
|
4665
|
-
__privateAdd(this, _publishState, 0);
|
|
4666
|
-
__privateAdd(this, _publisherTransport, null);
|
|
4667
|
-
__privateSet(this, _publisherTransport, null);
|
|
4533
|
+
this.#publisherTransport = null;
|
|
4668
4534
|
switch (options.publishTransportBaseOptions.transportType) {
|
|
4669
4535
|
case TransportType.RESTAPI:
|
|
4670
|
-
|
|
4536
|
+
this.#publisherTransport = new PublishTransportRESTServer(options.publishTransportBaseOptions);
|
|
4671
4537
|
break;
|
|
4672
4538
|
}
|
|
4673
|
-
|
|
4539
|
+
this.#UpdateState(0, "constructor()");
|
|
4674
4540
|
}
|
|
4675
4541
|
get options() {
|
|
4676
4542
|
return super.options;
|
|
4677
4543
|
}
|
|
4678
4544
|
async Publish() {
|
|
4679
|
-
if (
|
|
4545
|
+
if (this.#inPublish) {
|
|
4680
4546
|
return false;
|
|
4681
4547
|
}
|
|
4682
|
-
if (
|
|
4548
|
+
if (this.#publisherTransport) {
|
|
4683
4549
|
try {
|
|
4684
|
-
|
|
4550
|
+
this.#inPublish = true;
|
|
4685
4551
|
if (this.options.publishInstrumentController) {
|
|
4686
4552
|
const instrumentPayload = this.options.publishInstrumentController.GetPayloadData();
|
|
4687
|
-
return await
|
|
4553
|
+
return await this.#publisherTransport.Publish(instrumentPayload);
|
|
4688
4554
|
}
|
|
4689
4555
|
return false;
|
|
4690
4556
|
} catch (error) {
|
|
4691
4557
|
return false;
|
|
4692
4558
|
} finally {
|
|
4693
|
-
|
|
4559
|
+
this.#inPublish = false;
|
|
4694
4560
|
}
|
|
4695
4561
|
} else {
|
|
4696
4562
|
return false;
|
|
4697
4563
|
}
|
|
4698
4564
|
}
|
|
4565
|
+
#PublishTimeoutLoop(publishInterval) {
|
|
4566
|
+
this.#observer = setTimeout(async () => {
|
|
4567
|
+
const start = performance.now();
|
|
4568
|
+
const result = await this.Publish();
|
|
4569
|
+
const end = performance.now();
|
|
4570
|
+
const diff = end - start;
|
|
4571
|
+
if (this.#publishState === 1) {
|
|
4572
|
+
if (result === true) {
|
|
4573
|
+
this.#PublishTimeoutLoop(this.options.publishInterval - diff);
|
|
4574
|
+
} else {
|
|
4575
|
+
this.#PublishTimeoutLoop(this.options.publishPostFailInterval - diff);
|
|
4576
|
+
}
|
|
4577
|
+
}
|
|
4578
|
+
}, publishInterval);
|
|
4579
|
+
if (isNode) this.#observer.unref();
|
|
4580
|
+
}
|
|
4699
4581
|
async StartPublish() {
|
|
4700
|
-
if (
|
|
4701
|
-
this.options.logger.debug(chalk.yellow(`StartPublish:${this.options.processContext.nid}: StartPublish called when not currently in the init state. Current State: [${
|
|
4582
|
+
if (this.#publishState !== 0) {
|
|
4583
|
+
this.options.logger.debug(chalk.yellow(`StartPublish:${this.options.processContext.nid}: StartPublish called when not currently in the init state. Current State: [${this.#publishState}]`));
|
|
4702
4584
|
return false;
|
|
4703
4585
|
}
|
|
4704
|
-
|
|
4705
|
-
|
|
4586
|
+
this.#UpdateState(1, "StartPublish()");
|
|
4587
|
+
this.#PublishTimeoutLoop(this.options.publishInterval);
|
|
4706
4588
|
return true;
|
|
4707
4589
|
}
|
|
4590
|
+
#UpdateState(newState, comment) {
|
|
4591
|
+
const previousState = this.#publishState;
|
|
4592
|
+
this.#publishState = newState;
|
|
4593
|
+
this.options.logger.debug(chalk.yellow(`#UpdateState:${this.options.processContext.nid}: Previous State: [${previousState}]. Current State: [${this.#publishState}]. Comment: [${comment}]`));
|
|
4594
|
+
}
|
|
4708
4595
|
async EndPublish() {
|
|
4709
|
-
if (
|
|
4710
|
-
this.options.logger.debug(chalk.yellow(`EndPublish:${this.options.processContext.nid}: EndPublish called when not within the started state. Current State: [${
|
|
4596
|
+
if (this.#publishState !== 1) {
|
|
4597
|
+
this.options.logger.debug(chalk.yellow(`EndPublish:${this.options.processContext.nid}: EndPublish called when not within the started state. Current State: [${this.#publishState}]`));
|
|
4711
4598
|
return false;
|
|
4712
4599
|
}
|
|
4713
|
-
|
|
4714
|
-
if (
|
|
4715
|
-
clearTimeout(
|
|
4716
|
-
|
|
4600
|
+
this.#UpdateState(2, "EndPublish() (1)");
|
|
4601
|
+
if (this.#observer !== null) {
|
|
4602
|
+
clearTimeout(this.#observer);
|
|
4603
|
+
this.#observer = null;
|
|
4717
4604
|
await this.Publish();
|
|
4718
4605
|
}
|
|
4719
|
-
if (
|
|
4720
|
-
await
|
|
4606
|
+
if (this.#publisherTransport) {
|
|
4607
|
+
await this.#publisherTransport.Close();
|
|
4721
4608
|
}
|
|
4722
|
-
|
|
4609
|
+
this.#UpdateState(0, "EndPublish() (2)");
|
|
4723
4610
|
return true;
|
|
4724
4611
|
}
|
|
4725
4612
|
}
|
|
4726
|
-
_inPublish = new WeakMap();
|
|
4727
|
-
_observer2 = new WeakMap();
|
|
4728
|
-
_publishState = new WeakMap();
|
|
4729
|
-
_publisherTransport = new WeakMap();
|
|
4730
|
-
_PublishInstruments_instances = new WeakSet();
|
|
4731
|
-
PublishTimeoutLoop_fn = function(publishInterval) {
|
|
4732
|
-
__privateSet(this, _observer2, setTimeout(async () => {
|
|
4733
|
-
const start = performance.now();
|
|
4734
|
-
const result = await this.Publish();
|
|
4735
|
-
const end = performance.now();
|
|
4736
|
-
const diff = end - start;
|
|
4737
|
-
if (__privateGet(this, _publishState) === 1) {
|
|
4738
|
-
if (result === true) {
|
|
4739
|
-
__privateMethod(this, _PublishInstruments_instances, PublishTimeoutLoop_fn).call(this, this.options.publishInterval - diff);
|
|
4740
|
-
} else {
|
|
4741
|
-
__privateMethod(this, _PublishInstruments_instances, PublishTimeoutLoop_fn).call(this, this.options.publishPostFailInterval - diff);
|
|
4742
|
-
}
|
|
4743
|
-
}
|
|
4744
|
-
}, publishInterval));
|
|
4745
|
-
if (isNode) __privateGet(this, _observer2).unref();
|
|
4746
|
-
};
|
|
4747
|
-
UpdateState_fn = function(newState, comment) {
|
|
4748
|
-
const previousState = __privateGet(this, _publishState);
|
|
4749
|
-
__privateSet(this, _publishState, newState);
|
|
4750
|
-
this.options.logger.debug(chalk.yellow(`#UpdateState:${this.options.processContext.nid}: Previous State: [${previousState}]. Current State: [${__privateGet(this, _publishState)}]. Comment: [${comment}]`));
|
|
4751
|
-
};
|
|
4752
4613
|
var ePublishState = /* @__PURE__ */ ((ePublishState2) => {
|
|
4753
4614
|
ePublishState2[ePublishState2["init"] = 0] = "init";
|
|
4754
4615
|
ePublishState2[ePublishState2["started"] = 1] = "started";
|
|
4755
4616
|
ePublishState2[ePublishState2["stopping"] = 2] = "stopping";
|
|
4756
4617
|
return ePublishState2;
|
|
4757
4618
|
})(ePublishState || {});
|
|
4758
|
-
|
|
4619
|
+
class PublishInstrumentController extends STSOptionsBase {
|
|
4620
|
+
#instruments = {};
|
|
4621
|
+
#publisher = null;
|
|
4759
4622
|
constructor(options) {
|
|
4760
4623
|
super(options);
|
|
4761
|
-
__privateAdd(this, _PublishInstrumentController_instances);
|
|
4762
|
-
__privateAdd(this, _instruments, {});
|
|
4763
|
-
__privateAdd(this, _publisher, null);
|
|
4764
|
-
__publicField(this, "LogEx", (message) => {
|
|
4765
|
-
this.UpdateInstrument(Gauge.LOGGER, {
|
|
4766
|
-
LogMessage: message
|
|
4767
|
-
});
|
|
4768
|
-
});
|
|
4769
4624
|
this.SetupInstrumentation();
|
|
4770
4625
|
const publishInstrumentsOptions = {
|
|
4771
4626
|
logger: options.logger,
|
|
@@ -4775,7 +4630,7 @@ const _PublishInstrumentController = class _PublishInstrumentController extends
|
|
|
4775
4630
|
publishInstrumentController: this,
|
|
4776
4631
|
publishTransportBaseOptions: { ...options.publishTransportBaseOptions }
|
|
4777
4632
|
};
|
|
4778
|
-
|
|
4633
|
+
this.#publisher = new PublishInstruments(publishInstrumentsOptions);
|
|
4779
4634
|
if (this.options.autoStart === true) {
|
|
4780
4635
|
this.StartPublish();
|
|
4781
4636
|
}
|
|
@@ -4784,17 +4639,67 @@ const _PublishInstrumentController = class _PublishInstrumentController extends
|
|
|
4784
4639
|
return super.options;
|
|
4785
4640
|
}
|
|
4786
4641
|
async StartPublish() {
|
|
4787
|
-
return
|
|
4642
|
+
return this.#publisher.StartPublish();
|
|
4788
4643
|
}
|
|
4789
4644
|
async EndPublish() {
|
|
4790
|
-
return
|
|
4645
|
+
return this.#publisher.EndPublish();
|
|
4791
4646
|
}
|
|
4792
4647
|
async Publish() {
|
|
4793
|
-
return
|
|
4648
|
+
return this.#publisher.Publish();
|
|
4649
|
+
}
|
|
4650
|
+
LogEx = (message) => {
|
|
4651
|
+
this.UpdateInstrument(Gauge.LOGGER, {
|
|
4652
|
+
LogMessage: message
|
|
4653
|
+
});
|
|
4654
|
+
};
|
|
4655
|
+
#GetInstrument(instrumentName) {
|
|
4656
|
+
return this.#instruments[instrumentName];
|
|
4657
|
+
}
|
|
4658
|
+
#ProcessTelemetryCommand(instrumentName, telemetry) {
|
|
4659
|
+
const instrument = this.#GetInstrument(instrumentName);
|
|
4660
|
+
if (instrument) {
|
|
4661
|
+
instrument.ProcessTelemetry(telemetry);
|
|
4662
|
+
}
|
|
4663
|
+
}
|
|
4664
|
+
// Instrument factory
|
|
4665
|
+
#CreateInstrument(instrumentType, options) {
|
|
4666
|
+
let instrument;
|
|
4667
|
+
switch (instrumentType) {
|
|
4668
|
+
case GaugeTypes.INSTRUMENT_GAUGE:
|
|
4669
|
+
instrument = new InstrumentGauge(options);
|
|
4670
|
+
break;
|
|
4671
|
+
case GaugeTypes.INSTRUMENT_HISTOGRAM:
|
|
4672
|
+
instrument = new InstrumentHistogram(options);
|
|
4673
|
+
break;
|
|
4674
|
+
case GaugeTypes.INSTRUMENT_LOG:
|
|
4675
|
+
instrument = new InstrumentLog(options);
|
|
4676
|
+
break;
|
|
4677
|
+
case GaugeTypes.INSTRUMENT_OBJECT:
|
|
4678
|
+
instrument = new InstrumentObject(options);
|
|
4679
|
+
break;
|
|
4680
|
+
case GaugeTypes.INSTRUMENT_TIMER:
|
|
4681
|
+
instrument = new InstrumentTimerGauge(options);
|
|
4682
|
+
break;
|
|
4683
|
+
case GaugeTypes.INSTRUMENT_VELOCITY:
|
|
4684
|
+
instrument = new InstrumentVelocity(options);
|
|
4685
|
+
break;
|
|
4686
|
+
default:
|
|
4687
|
+
throw new Error(`Gauge type: [${instrumentType} not known.]`);
|
|
4688
|
+
}
|
|
4689
|
+
return instrument;
|
|
4690
|
+
}
|
|
4691
|
+
#CreateInstruments(payload) {
|
|
4692
|
+
payload.forEach((instrumentDefinition) => {
|
|
4693
|
+
const g = instrumentDefinition[0];
|
|
4694
|
+
const gt = instrumentDefinition[1];
|
|
4695
|
+
const instrumentBaseOptions = instrumentDefinition[2];
|
|
4696
|
+
const instrument = this.#CreateInstrument(gt, instrumentBaseOptions);
|
|
4697
|
+
this.#instruments[g] = instrument;
|
|
4698
|
+
});
|
|
4794
4699
|
}
|
|
4795
4700
|
GetPayloadData() {
|
|
4796
4701
|
const context = this.options.processContext;
|
|
4797
|
-
const instruments =
|
|
4702
|
+
const instruments = this.#instruments;
|
|
4798
4703
|
const payloadInstruments = {};
|
|
4799
4704
|
for (const [key, value] of Object.entries(instruments)) {
|
|
4800
4705
|
if (value instanceof InstrumentLog) {
|
|
@@ -4817,7 +4722,7 @@ const _PublishInstrumentController = class _PublishInstrumentController extends
|
|
|
4817
4722
|
this.options.logger.debug(chalk.yellow(`SetupInstrumentation: No context defined within supplied options.`));
|
|
4818
4723
|
return;
|
|
4819
4724
|
}
|
|
4820
|
-
|
|
4725
|
+
this.#CreateInstruments(this.options.instrumentDefinitions);
|
|
4821
4726
|
}
|
|
4822
4727
|
/**
|
|
4823
4728
|
* Check if an instrument exists within the managed instrument collection
|
|
@@ -4825,7 +4730,7 @@ const _PublishInstrumentController = class _PublishInstrumentController extends
|
|
|
4825
4730
|
* @returns
|
|
4826
4731
|
*/
|
|
4827
4732
|
InstrumentExists(instrumentName) {
|
|
4828
|
-
if (
|
|
4733
|
+
if (this.#instruments[instrumentName]) {
|
|
4829
4734
|
return true;
|
|
4830
4735
|
}
|
|
4831
4736
|
return false;
|
|
@@ -4836,8 +4741,8 @@ const _PublishInstrumentController = class _PublishInstrumentController extends
|
|
|
4836
4741
|
* @param telemetry
|
|
4837
4742
|
*/
|
|
4838
4743
|
UpdateInstrument(instrumentName, telemetry) {
|
|
4839
|
-
if (
|
|
4840
|
-
|
|
4744
|
+
if (this.#instruments[instrumentName]) {
|
|
4745
|
+
this.#ProcessTelemetryCommand(instrumentName, telemetry);
|
|
4841
4746
|
} else {
|
|
4842
4747
|
this.options.logger.debug(chalk.red(`UpdateInstrument:${this.options.processContext.nid}: Attempted to UpdateInstrument before initialised.`));
|
|
4843
4748
|
}
|
|
@@ -4850,58 +4755,9 @@ const _PublishInstrumentController = class _PublishInstrumentController extends
|
|
|
4850
4755
|
AddPublishInstrumentController(processContext) {
|
|
4851
4756
|
const options = { ...this.options };
|
|
4852
4757
|
options.processContext = processContext;
|
|
4853
|
-
return new
|
|
4854
|
-
}
|
|
4855
|
-
};
|
|
4856
|
-
_instruments = new WeakMap();
|
|
4857
|
-
_publisher = new WeakMap();
|
|
4858
|
-
_PublishInstrumentController_instances = new WeakSet();
|
|
4859
|
-
GetInstrument_fn = function(instrumentName) {
|
|
4860
|
-
return __privateGet(this, _instruments)[instrumentName];
|
|
4861
|
-
};
|
|
4862
|
-
ProcessTelemetryCommand_fn = function(instrumentName, telemetry) {
|
|
4863
|
-
const instrument = __privateMethod(this, _PublishInstrumentController_instances, GetInstrument_fn).call(this, instrumentName);
|
|
4864
|
-
if (instrument) {
|
|
4865
|
-
instrument.ProcessTelemetry(telemetry);
|
|
4866
|
-
}
|
|
4867
|
-
};
|
|
4868
|
-
// Instrument factory
|
|
4869
|
-
CreateInstrument_fn = function(instrumentType, options) {
|
|
4870
|
-
let instrument;
|
|
4871
|
-
switch (instrumentType) {
|
|
4872
|
-
case GaugeTypes.INSTRUMENT_GAUGE:
|
|
4873
|
-
instrument = new InstrumentGauge(options);
|
|
4874
|
-
break;
|
|
4875
|
-
case GaugeTypes.INSTRUMENT_HISTOGRAM:
|
|
4876
|
-
instrument = new InstrumentHistogram(options);
|
|
4877
|
-
break;
|
|
4878
|
-
case GaugeTypes.INSTRUMENT_LOG:
|
|
4879
|
-
instrument = new InstrumentLog(options);
|
|
4880
|
-
break;
|
|
4881
|
-
case GaugeTypes.INSTRUMENT_OBJECT:
|
|
4882
|
-
instrument = new InstrumentObject(options);
|
|
4883
|
-
break;
|
|
4884
|
-
case GaugeTypes.INSTRUMENT_TIMER:
|
|
4885
|
-
instrument = new InstrumentTimerGauge(options);
|
|
4886
|
-
break;
|
|
4887
|
-
case GaugeTypes.INSTRUMENT_VELOCITY:
|
|
4888
|
-
instrument = new InstrumentVelocity(options);
|
|
4889
|
-
break;
|
|
4890
|
-
default:
|
|
4891
|
-
throw new Error(`Gauge type: [${instrumentType} not known.]`);
|
|
4758
|
+
return new PublishInstrumentController(options);
|
|
4892
4759
|
}
|
|
4893
|
-
|
|
4894
|
-
};
|
|
4895
|
-
CreateInstruments_fn = function(payload) {
|
|
4896
|
-
payload.forEach((instrumentDefinition) => {
|
|
4897
|
-
const g = instrumentDefinition[0];
|
|
4898
|
-
const gt = instrumentDefinition[1];
|
|
4899
|
-
const instrumentBaseOptions = instrumentDefinition[2];
|
|
4900
|
-
const instrument = __privateMethod(this, _PublishInstrumentController_instances, CreateInstrument_fn).call(this, gt, instrumentBaseOptions);
|
|
4901
|
-
__privateGet(this, _instruments)[g] = instrument;
|
|
4902
|
-
});
|
|
4903
|
-
};
|
|
4904
|
-
let PublishInstrumentController = _PublishInstrumentController;
|
|
4760
|
+
}
|
|
4905
4761
|
const STSInstrumentControllerPluginKey = Symbol("instrumentController");
|
|
4906
4762
|
const GetSTSInstrumentControllerPluginKey = () => STSInstrumentControllerPluginKey;
|
|
4907
4763
|
const CompareSTSInstrumentControllerPluginKey = (val) => val === STSInstrumentControllerPluginKey;
|
|
@@ -5271,7 +5127,7 @@ const GetInstruments = (service) => {
|
|
|
5271
5127
|
});
|
|
5272
5128
|
return retVal;
|
|
5273
5129
|
};
|
|
5274
|
-
|
|
5130
|
+
class ObservabilityModelUtils {
|
|
5275
5131
|
static GetModelNode(data) {
|
|
5276
5132
|
const fixedSize = 2;
|
|
5277
5133
|
const padLength = 9;
|
|
@@ -5369,6 +5225,42 @@ const _ObservabilityModelUtils = class _ObservabilityModelUtils {
|
|
|
5369
5225
|
};
|
|
5370
5226
|
}
|
|
5371
5227
|
}
|
|
5228
|
+
static ParseModelNode = (model, data, parseLog, gaugeName, fieldName) => {
|
|
5229
|
+
if (fieldName in data) {
|
|
5230
|
+
model.instruments[gaugeName] = this.GetModelNode(data[fieldName]);
|
|
5231
|
+
} else {
|
|
5232
|
+
parseLog.push(`ObservabilityModelUtils:ParseModelNode(): Field not present: [${fieldName}], default to [0]`);
|
|
5233
|
+
model.instruments[gaugeName] = this.GetModelNode(0);
|
|
5234
|
+
}
|
|
5235
|
+
};
|
|
5236
|
+
static ParseModelNodeWithQuantile = (model, data, parseLog, gaugeName, fieldName, quantileFieldName) => {
|
|
5237
|
+
if (fieldName in data && quantileFieldName in data) {
|
|
5238
|
+
model.instruments[gaugeName] = this.GetModelNodeWithQuantile(data[fieldName], data[quantileFieldName]);
|
|
5239
|
+
} else if (fieldName in data) {
|
|
5240
|
+
const dataVal = data[fieldName];
|
|
5241
|
+
parseLog.push(`ObservabilityModelUtils:ParseModelNodeWithQuantile(): QuantileFieldName not present: [${quantileFieldName}], default to [${dataVal},{}]`);
|
|
5242
|
+
model.instruments[gaugeName] = this.GetModelNodeWithQuantile(dataVal, {});
|
|
5243
|
+
} else {
|
|
5244
|
+
parseLog.push(`ObservabilityModelUtils:ParseModelNodeWithQuantile(): Field not present: [${fieldName}], QuantileFieldName not present: [${quantileFieldName}], default to [0,{}]`);
|
|
5245
|
+
model.instruments[gaugeName] = this.GetModelNodeWithQuantile(0, {});
|
|
5246
|
+
}
|
|
5247
|
+
};
|
|
5248
|
+
static ParseModelNodeHisto = (model, data, parseLog, gaugeName, fieldName) => {
|
|
5249
|
+
if (fieldName in data) {
|
|
5250
|
+
model.instruments[gaugeName] = this.GetModelNodeHistFromInfluxData(data[fieldName]);
|
|
5251
|
+
} else {
|
|
5252
|
+
parseLog.push(`ObservabilityModelUtils:ParseModelNodeHisto(): Field not present: [${fieldName}], default to [{}]`);
|
|
5253
|
+
model.instruments[gaugeName] = this.GetModelNodeHistFromInfluxData({});
|
|
5254
|
+
}
|
|
5255
|
+
};
|
|
5256
|
+
static ParseModelNodeObject = (model, data, parseLog, gaugeName, fieldName) => {
|
|
5257
|
+
if (fieldName in data) {
|
|
5258
|
+
model.instruments[gaugeName] = this.GetModelNodeObject(data[fieldName]);
|
|
5259
|
+
} else {
|
|
5260
|
+
parseLog.push(`ObservabilityModelUtils:ParseModelNodeObject(): Field not present: [${fieldName}], default to [{}]`);
|
|
5261
|
+
model.instruments[gaugeName] = this.GetModelNodeObject({});
|
|
5262
|
+
}
|
|
5263
|
+
};
|
|
5372
5264
|
static GetModelData(serviceType, model, data, parseLog) {
|
|
5373
5265
|
const fieldList = [
|
|
5374
5266
|
...globalServiceDefinitions.coreFieldList,
|
|
@@ -5376,14 +5268,14 @@ const _ObservabilityModelUtils = class _ObservabilityModelUtils {
|
|
|
5376
5268
|
];
|
|
5377
5269
|
fieldList.forEach((field) => {
|
|
5378
5270
|
if (field.quantile) {
|
|
5379
|
-
|
|
5271
|
+
ObservabilityModelUtils.ParseModelNodeWithQuantile(model, data, parseLog, field.gauge, field.fieldName, `${field.fieldName}_quantile`);
|
|
5380
5272
|
} else if (field.gaugeType.localeCompare(GaugeTypes.INSTRUMENT_OBJECT) === 0) {
|
|
5381
|
-
|
|
5273
|
+
ObservabilityModelUtils.ParseModelNodeObject(model, data, parseLog, field.gauge, field.fieldName);
|
|
5382
5274
|
} else {
|
|
5383
|
-
|
|
5275
|
+
ObservabilityModelUtils.ParseModelNode(model, data, parseLog, field.gauge, field.fieldName);
|
|
5384
5276
|
}
|
|
5385
5277
|
if (field.histo) {
|
|
5386
|
-
|
|
5278
|
+
ObservabilityModelUtils.ParseModelNodeHisto(model, data, parseLog, field.histoGauge, `${field.fieldName}_histo`);
|
|
5387
5279
|
}
|
|
5388
5280
|
});
|
|
5389
5281
|
}
|
|
@@ -5396,7 +5288,7 @@ const _ObservabilityModelUtils = class _ObservabilityModelUtils {
|
|
|
5396
5288
|
};
|
|
5397
5289
|
this.GetModelData("service", model, data, parseLog);
|
|
5398
5290
|
if (!subscribeToKafka) {
|
|
5399
|
-
model.instruments[Gauge.LOGGER] =
|
|
5291
|
+
model.instruments[Gauge.LOGGER] = ObservabilityModelUtils.GetModelNodeRawStringArray(data["logMessages"]);
|
|
5400
5292
|
}
|
|
5401
5293
|
if (parseLog.length > 0) {
|
|
5402
5294
|
parseLog.forEach((logEntry) => logger.debug(logEntry));
|
|
@@ -5415,7 +5307,7 @@ const _ObservabilityModelUtils = class _ObservabilityModelUtils {
|
|
|
5415
5307
|
};
|
|
5416
5308
|
this.GetModelData("lambda", model, data, parseLog);
|
|
5417
5309
|
if (!subscribeToKafka) {
|
|
5418
|
-
model.instruments[Gauge.LOGGER] =
|
|
5310
|
+
model.instruments[Gauge.LOGGER] = ObservabilityModelUtils.GetModelNodeRawStringArray(data["logMessages"]);
|
|
5419
5311
|
}
|
|
5420
5312
|
if (parseLog.length > 0) {
|
|
5421
5313
|
parseLog.forEach((logEntry) => logger.debug(logEntry));
|
|
@@ -5437,7 +5329,7 @@ const _ObservabilityModelUtils = class _ObservabilityModelUtils {
|
|
|
5437
5329
|
};
|
|
5438
5330
|
this.GetModelData("agent", model, data, parseLog);
|
|
5439
5331
|
if (!subscribeToKafka) {
|
|
5440
|
-
model.instruments[Gauge.LOGGER] =
|
|
5332
|
+
model.instruments[Gauge.LOGGER] = ObservabilityModelUtils.GetModelNodeRawStringArray(data["logMessages"]);
|
|
5441
5333
|
}
|
|
5442
5334
|
if (parseLog.length > 0) {
|
|
5443
5335
|
parseLog.forEach((logEntry) => logger.debug(logEntry));
|
|
@@ -5447,112 +5339,63 @@ const _ObservabilityModelUtils = class _ObservabilityModelUtils {
|
|
|
5447
5339
|
return null;
|
|
5448
5340
|
}
|
|
5449
5341
|
}
|
|
5450
|
-
}
|
|
5451
|
-
__publicField(_ObservabilityModelUtils, "ParseModelNode", (model, data, parseLog, gaugeName, fieldName) => {
|
|
5452
|
-
if (fieldName in data) {
|
|
5453
|
-
model.instruments[gaugeName] = _ObservabilityModelUtils.GetModelNode(data[fieldName]);
|
|
5454
|
-
} else {
|
|
5455
|
-
parseLog.push(`ObservabilityModelUtils:ParseModelNode(): Field not present: [${fieldName}], default to [0]`);
|
|
5456
|
-
model.instruments[gaugeName] = _ObservabilityModelUtils.GetModelNode(0);
|
|
5457
|
-
}
|
|
5458
|
-
});
|
|
5459
|
-
__publicField(_ObservabilityModelUtils, "ParseModelNodeWithQuantile", (model, data, parseLog, gaugeName, fieldName, quantileFieldName) => {
|
|
5460
|
-
if (fieldName in data && quantileFieldName in data) {
|
|
5461
|
-
model.instruments[gaugeName] = _ObservabilityModelUtils.GetModelNodeWithQuantile(data[fieldName], data[quantileFieldName]);
|
|
5462
|
-
} else if (fieldName in data) {
|
|
5463
|
-
const dataVal = data[fieldName];
|
|
5464
|
-
parseLog.push(`ObservabilityModelUtils:ParseModelNodeWithQuantile(): QuantileFieldName not present: [${quantileFieldName}], default to [${dataVal},{}]`);
|
|
5465
|
-
model.instruments[gaugeName] = _ObservabilityModelUtils.GetModelNodeWithQuantile(dataVal, {});
|
|
5466
|
-
} else {
|
|
5467
|
-
parseLog.push(`ObservabilityModelUtils:ParseModelNodeWithQuantile(): Field not present: [${fieldName}], QuantileFieldName not present: [${quantileFieldName}], default to [0,{}]`);
|
|
5468
|
-
model.instruments[gaugeName] = _ObservabilityModelUtils.GetModelNodeWithQuantile(0, {});
|
|
5469
|
-
}
|
|
5470
|
-
});
|
|
5471
|
-
__publicField(_ObservabilityModelUtils, "ParseModelNodeHisto", (model, data, parseLog, gaugeName, fieldName) => {
|
|
5472
|
-
if (fieldName in data) {
|
|
5473
|
-
model.instruments[gaugeName] = _ObservabilityModelUtils.GetModelNodeHistFromInfluxData(data[fieldName]);
|
|
5474
|
-
} else {
|
|
5475
|
-
parseLog.push(`ObservabilityModelUtils:ParseModelNodeHisto(): Field not present: [${fieldName}], default to [{}]`);
|
|
5476
|
-
model.instruments[gaugeName] = _ObservabilityModelUtils.GetModelNodeHistFromInfluxData({});
|
|
5477
|
-
}
|
|
5478
|
-
});
|
|
5479
|
-
__publicField(_ObservabilityModelUtils, "ParseModelNodeObject", (model, data, parseLog, gaugeName, fieldName) => {
|
|
5480
|
-
if (fieldName in data) {
|
|
5481
|
-
model.instruments[gaugeName] = _ObservabilityModelUtils.GetModelNodeObject(data[fieldName]);
|
|
5482
|
-
} else {
|
|
5483
|
-
parseLog.push(`ObservabilityModelUtils:ParseModelNodeObject(): Field not present: [${fieldName}], default to [{}]`);
|
|
5484
|
-
model.instruments[gaugeName] = _ObservabilityModelUtils.GetModelNodeObject({});
|
|
5485
|
-
}
|
|
5486
|
-
});
|
|
5487
|
-
let ObservabilityModelUtils = _ObservabilityModelUtils;
|
|
5342
|
+
}
|
|
5488
5343
|
class KafkaHelper {
|
|
5344
|
+
#kafkaLog = {};
|
|
5345
|
+
#maxLogLength;
|
|
5489
5346
|
constructor(options) {
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5347
|
+
this.#maxLogLength = options.maxLogLength;
|
|
5348
|
+
}
|
|
5349
|
+
GetKafkaLogData = (kafkaTopic, modelNode) => {
|
|
5350
|
+
if (this.#kafkaLog[kafkaTopic]) {
|
|
5351
|
+
modelNode.instruments[Gauge.LOGGER] = ObservabilityModelUtils.GetModelNodeRawStringArray(this.#kafkaLog[kafkaTopic].kafkaLog);
|
|
5352
|
+
}
|
|
5353
|
+
};
|
|
5354
|
+
ProcessKafkaData = (payload) => {
|
|
5355
|
+
const { data } = payload;
|
|
5356
|
+
if (data) {
|
|
5357
|
+
const kafkaData = data;
|
|
5358
|
+
const { kafkaTopic, value } = kafkaData;
|
|
5359
|
+
if (!this.#kafkaLog[kafkaTopic]) {
|
|
5360
|
+
this.#kafkaLog[kafkaTopic] = {
|
|
5361
|
+
kafkaTopic: `${kafkaTopic}`,
|
|
5362
|
+
//@@ why is this needed
|
|
5363
|
+
kafkaLog: []
|
|
5364
|
+
};
|
|
5495
5365
|
}
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
if (data) {
|
|
5500
|
-
const kafkaData = data;
|
|
5501
|
-
const { kafkaTopic, value } = kafkaData;
|
|
5502
|
-
if (!__privateGet(this, _kafkaLog)[kafkaTopic]) {
|
|
5503
|
-
__privateGet(this, _kafkaLog)[kafkaTopic] = {
|
|
5504
|
-
kafkaTopic: `${kafkaTopic}`,
|
|
5505
|
-
//@@ why is this needed
|
|
5506
|
-
kafkaLog: []
|
|
5507
|
-
};
|
|
5508
|
-
}
|
|
5509
|
-
__privateGet(this, _kafkaLog)[kafkaTopic].kafkaLog.push(value);
|
|
5510
|
-
while (__privateGet(this, _kafkaLog)[kafkaTopic].kafkaLog.length > __privateGet(this, _maxLogLength)) {
|
|
5511
|
-
__privateGet(this, _kafkaLog)[kafkaTopic].kafkaLog.shift();
|
|
5512
|
-
}
|
|
5366
|
+
this.#kafkaLog[kafkaTopic].kafkaLog.push(value);
|
|
5367
|
+
while (this.#kafkaLog[kafkaTopic].kafkaLog.length > this.#maxLogLength) {
|
|
5368
|
+
this.#kafkaLog[kafkaTopic].kafkaLog.shift();
|
|
5513
5369
|
}
|
|
5514
|
-
}
|
|
5515
|
-
|
|
5516
|
-
}
|
|
5370
|
+
}
|
|
5371
|
+
};
|
|
5517
5372
|
}
|
|
5518
|
-
_kafkaLog = new WeakMap();
|
|
5519
|
-
_maxLogLength = new WeakMap();
|
|
5520
5373
|
class ObservabilityRESTAPISubscriber {
|
|
5374
|
+
#socketSubscribeKeepAlive = {};
|
|
5375
|
+
#options;
|
|
5376
|
+
// This is required becuase each call to .bind create a new replica bound function - so we need the same instance for on/off event bindings.
|
|
5377
|
+
KeepAliveAckBoundFunction;
|
|
5521
5378
|
constructor(options) {
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
const retVal = await __privateMethod(this, _ObservabilityRESTAPISubscriber_instances, InvokeRESTAPI_fn).call(this, subscription);
|
|
5530
|
-
if (retVal) {
|
|
5531
|
-
const payload = {
|
|
5532
|
-
subscriptionKey: subscription.subscriptionKey,
|
|
5533
|
-
data: retVal
|
|
5534
|
-
};
|
|
5535
|
-
subscription.cb(payload);
|
|
5536
|
-
}
|
|
5537
|
-
} catch (error) {
|
|
5538
|
-
__privateMethod(this, _ObservabilityRESTAPISubscriber_instances, LogErrorMessage_fn).call(this, chalk.red(`ObservabilityRESTAPISubscriber:#AddKeepAlive(): Error response: [${JSON.stringify(error)}]`));
|
|
5539
|
-
__privateMethod(this, _ObservabilityRESTAPISubscriber_instances, RemoveKeepAlive_fn).call(this, subscription);
|
|
5540
|
-
}
|
|
5541
|
-
});
|
|
5542
|
-
__privateSet(this, _options2, options);
|
|
5379
|
+
this.#options = options;
|
|
5380
|
+
}
|
|
5381
|
+
#LogDebugMessage(message) {
|
|
5382
|
+
this.#options.logger.debug(message);
|
|
5383
|
+
}
|
|
5384
|
+
#LogErrorMessage(message) {
|
|
5385
|
+
this.#options.logger.error(message);
|
|
5543
5386
|
}
|
|
5544
5387
|
SubscribeOne(subscription) {
|
|
5545
5388
|
this.Subscribe([subscription]);
|
|
5546
5389
|
}
|
|
5547
5390
|
async Subscribe(subscriptions) {
|
|
5548
5391
|
subscriptions.map(async (subId) => {
|
|
5549
|
-
|
|
5550
|
-
|
|
5392
|
+
this.#RemoveKeepAlive(subId);
|
|
5393
|
+
this.#LogDebugMessage(chalk.yellow(`ObservabilityRESTAPISubscriber:Subscribe(): Sending subscribe: subscriptionKey: [${subId.subscriptionKey.id}]`));
|
|
5551
5394
|
try {
|
|
5552
|
-
|
|
5395
|
+
this.#AddKeepAlive(subId);
|
|
5553
5396
|
} catch (error) {
|
|
5554
|
-
|
|
5555
|
-
|
|
5397
|
+
this.#LogErrorMessage(chalk.red(`ObservabilityRESTAPISubscriber:Subscribe(): Error: response: [${JSON.stringify(error)}]`));
|
|
5398
|
+
this.#RemoveKeepAlive(subId);
|
|
5556
5399
|
}
|
|
5557
5400
|
});
|
|
5558
5401
|
}
|
|
@@ -5561,159 +5404,164 @@ class ObservabilityRESTAPISubscriber {
|
|
|
5561
5404
|
}
|
|
5562
5405
|
UnSubscribe(subscriptions) {
|
|
5563
5406
|
subscriptions.map(async (subId) => {
|
|
5564
|
-
|
|
5565
|
-
|
|
5407
|
+
this.#RemoveKeepAlive(subId);
|
|
5408
|
+
this.#LogDebugMessage(chalk.yellow(`ObservabilityRESTAPISubscriber:UnSubscribe(): Sending unsubscribe: subscriptionKey: [${subId.subscriptionKey.id}]`));
|
|
5566
5409
|
});
|
|
5567
5410
|
}
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
LogErrorMessage_fn = function(message) {
|
|
5576
|
-
__privateGet(this, _options2).logger.error(message);
|
|
5577
|
-
};
|
|
5578
|
-
InvokeRESTAPI_fn = async function(subscription) {
|
|
5579
|
-
const { subscriptionKey } = subscription;
|
|
5580
|
-
let url = "";
|
|
5581
|
-
switch (subscriptionKey.topic) {
|
|
5582
|
-
// Services -------------------------------------------------------------------------------------------
|
|
5583
|
-
case SubscriptionTopic.AllServicesCombined:
|
|
5584
|
-
url = `/metrics`;
|
|
5585
|
-
break;
|
|
5586
|
-
case SubscriptionTopic.Services:
|
|
5587
|
-
url = `/metrics/services`;
|
|
5588
|
-
break;
|
|
5589
|
-
case SubscriptionTopic.ServiceInstances:
|
|
5590
|
-
if (subscriptionKey.key) {
|
|
5591
|
-
url = `/metrics/services/${subscriptionKey.key}`;
|
|
5411
|
+
async #InvokeRESTAPI(subscription) {
|
|
5412
|
+
const { subscriptionKey } = subscription;
|
|
5413
|
+
let url = "";
|
|
5414
|
+
switch (subscriptionKey.topic) {
|
|
5415
|
+
// Services -------------------------------------------------------------------------------------------
|
|
5416
|
+
case SubscriptionTopic.AllServicesCombined:
|
|
5417
|
+
url = `/metrics`;
|
|
5592
5418
|
break;
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
}
|
|
5596
|
-
case SubscriptionTopic.ServiceInstance:
|
|
5597
|
-
url = `/metrics/services/${subscriptionKey.key}`;
|
|
5598
|
-
if (subscriptionKey.key && subscriptionKey.subkey) {
|
|
5599
|
-
url = `/metrics/services/${subscriptionKey.key}/${subscriptionKey.subkey}`;
|
|
5419
|
+
case SubscriptionTopic.Services:
|
|
5420
|
+
url = `/metrics/services`;
|
|
5600
5421
|
break;
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5422
|
+
case SubscriptionTopic.ServiceInstances:
|
|
5423
|
+
if (subscriptionKey.key) {
|
|
5424
|
+
url = `/metrics/services/${subscriptionKey.key}`;
|
|
5425
|
+
break;
|
|
5426
|
+
} else {
|
|
5427
|
+
throw new Error(`#OutputSubscription(Services): key not provided for subscription: [${JSON.stringify(subscriptionKey)}]`);
|
|
5428
|
+
}
|
|
5429
|
+
case SubscriptionTopic.ServiceInstance:
|
|
5430
|
+
url = `/metrics/services/${subscriptionKey.key}`;
|
|
5431
|
+
if (subscriptionKey.key && subscriptionKey.subkey) {
|
|
5432
|
+
url = `/metrics/services/${subscriptionKey.key}/${subscriptionKey.subkey}`;
|
|
5433
|
+
break;
|
|
5434
|
+
} else {
|
|
5435
|
+
throw new Error(`#OutputSubscription(Services): key not provided for subscription: [${JSON.stringify(subscriptionKey)}]`);
|
|
5436
|
+
}
|
|
5437
|
+
// Lambdas -------------------------------------------------------------------------------------------
|
|
5438
|
+
case SubscriptionTopic.AllLambdasCombined:
|
|
5439
|
+
url = `/metrics`;
|
|
5614
5440
|
break;
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
}
|
|
5618
|
-
case SubscriptionTopic.LambdaSubTechnologiesInstance:
|
|
5619
|
-
url = `/metrics/lambdas/${subscriptionKey.key}`;
|
|
5620
|
-
if (subscriptionKey.key && subscriptionKey.subkey) {
|
|
5621
|
-
url = `/metrics/lambdas/${subscriptionKey.key}/${subscriptionKey.subkey}`;
|
|
5441
|
+
case SubscriptionTopic.LambdaTechnologies:
|
|
5442
|
+
url = `/metrics/lambdas`;
|
|
5622
5443
|
break;
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5444
|
+
case SubscriptionTopic.LambdaSubTechnologies:
|
|
5445
|
+
if (subscriptionKey.key) {
|
|
5446
|
+
url = `/metrics/lambdas/${subscriptionKey.key}`;
|
|
5447
|
+
break;
|
|
5448
|
+
} else {
|
|
5449
|
+
throw new Error(`#OutputSubscription(Lambdas): key not provided for subscription: [${JSON.stringify(subscriptionKey)}]`);
|
|
5450
|
+
}
|
|
5451
|
+
case SubscriptionTopic.LambdaSubTechnologiesInstance:
|
|
5452
|
+
url = `/metrics/lambdas/${subscriptionKey.key}`;
|
|
5453
|
+
if (subscriptionKey.key && subscriptionKey.subkey) {
|
|
5454
|
+
url = `/metrics/lambdas/${subscriptionKey.key}/${subscriptionKey.subkey}`;
|
|
5455
|
+
break;
|
|
5456
|
+
} else {
|
|
5457
|
+
throw new Error(`#OutputSubscription(Lambdas): key not provided for subscription: [${JSON.stringify(subscriptionKey)}]`);
|
|
5458
|
+
}
|
|
5459
|
+
// User Agents -------------------------------------------------------------------------------------------
|
|
5460
|
+
case SubscriptionTopic.AllAgentsCombined:
|
|
5461
|
+
url = `/metrics`;
|
|
5636
5462
|
break;
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
}
|
|
5640
|
-
case SubscriptionTopic.AgentWorker:
|
|
5641
|
-
if (subscriptionKey.key && subscriptionKey.subkey) {
|
|
5642
|
-
url = `/metrics/agents/${subscriptionKey.key}/${subscriptionKey.subkey}`;
|
|
5463
|
+
case SubscriptionTopic.Agents:
|
|
5464
|
+
url = `/metrics/agents`;
|
|
5643
5465
|
break;
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
const end = performance.now();
|
|
5659
|
-
const diff = end - start;
|
|
5660
|
-
if (subscriptionKey.topic.localeCompare(SubscriptionTopic.AllServicesCombined) === 0) {
|
|
5661
|
-
return retVal.data["services"].data;
|
|
5662
|
-
}
|
|
5663
|
-
if (subscriptionKey.topic.localeCompare(SubscriptionTopic.AllAgentsCombined) === 0) {
|
|
5664
|
-
return retVal.data["agents"].data;
|
|
5665
|
-
}
|
|
5666
|
-
if (subscriptionKey.topic.localeCompare(SubscriptionTopic.AllLambdasCombined) === 0) {
|
|
5667
|
-
return retVal.data["lambdas"].data;
|
|
5668
|
-
}
|
|
5669
|
-
return retVal.data;
|
|
5670
|
-
} catch (error) {
|
|
5671
|
-
return null;
|
|
5466
|
+
case SubscriptionTopic.AgentWorkers:
|
|
5467
|
+
if (subscriptionKey.key) {
|
|
5468
|
+
url = `/metrics/agents/${subscriptionKey.key}`;
|
|
5469
|
+
break;
|
|
5470
|
+
} else {
|
|
5471
|
+
throw new Error(`#OutputSubscription(Agents): key not provided for subscription: [${JSON.stringify(subscriptionKey)}]`);
|
|
5472
|
+
}
|
|
5473
|
+
case SubscriptionTopic.AgentWorker:
|
|
5474
|
+
if (subscriptionKey.key && subscriptionKey.subkey) {
|
|
5475
|
+
url = `/metrics/agents/${subscriptionKey.key}/${subscriptionKey.subkey}`;
|
|
5476
|
+
break;
|
|
5477
|
+
} else {
|
|
5478
|
+
throw new Error(`#OutputSubscription(Agents): key and/or subkey not provided for subscription: [${JSON.stringify(subscriptionKey.topic)}]`);
|
|
5479
|
+
}
|
|
5672
5480
|
}
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
};
|
|
5677
|
-
_GetData = new WeakMap();
|
|
5678
|
-
SetupTimeout_fn = function(socketSubscribeKeepAlive, subscription, timeout) {
|
|
5679
|
-
return setTimeout(async () => {
|
|
5680
|
-
try {
|
|
5481
|
+
if (url.localeCompare("") !== 0) {
|
|
5482
|
+
const endPointUrl = `${this.#options.urlBase}${url}`;
|
|
5483
|
+
let retVal;
|
|
5681
5484
|
const start = performance.now();
|
|
5682
|
-
|
|
5683
|
-
|
|
5485
|
+
try {
|
|
5486
|
+
if (isNode && this.#options.agentManager) {
|
|
5487
|
+
retVal = await axios(new STSAxiosConfig(endPointUrl, "get").withDefaultHeaders().withAgentManager(this.#options.agentManager).config);
|
|
5488
|
+
} else {
|
|
5489
|
+
retVal = await axios(new STSAxiosConfig(endPointUrl, "get").withDefaultHeaders().config);
|
|
5490
|
+
}
|
|
5684
5491
|
const end = performance.now();
|
|
5685
5492
|
const diff = end - start;
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
timeoutDuration = 500;
|
|
5493
|
+
if (subscriptionKey.topic.localeCompare(SubscriptionTopic.AllServicesCombined) === 0) {
|
|
5494
|
+
return retVal.data["services"].data;
|
|
5689
5495
|
}
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
|
|
5496
|
+
if (subscriptionKey.topic.localeCompare(SubscriptionTopic.AllAgentsCombined) === 0) {
|
|
5497
|
+
return retVal.data["agents"].data;
|
|
5498
|
+
}
|
|
5499
|
+
if (subscriptionKey.topic.localeCompare(SubscriptionTopic.AllLambdasCombined) === 0) {
|
|
5500
|
+
return retVal.data["lambdas"].data;
|
|
5501
|
+
}
|
|
5502
|
+
return retVal.data;
|
|
5503
|
+
} catch (error) {
|
|
5504
|
+
return null;
|
|
5505
|
+
}
|
|
5506
|
+
} else {
|
|
5507
|
+
return null;
|
|
5508
|
+
}
|
|
5509
|
+
}
|
|
5510
|
+
#GetData = async (subscription) => {
|
|
5511
|
+
try {
|
|
5512
|
+
const retVal = await this.#InvokeRESTAPI(subscription);
|
|
5513
|
+
if (retVal) {
|
|
5514
|
+
const payload = {
|
|
5515
|
+
subscriptionKey: subscription.subscriptionKey,
|
|
5516
|
+
data: retVal
|
|
5517
|
+
};
|
|
5518
|
+
subscription.cb(payload);
|
|
5693
5519
|
}
|
|
5694
5520
|
} catch (error) {
|
|
5695
|
-
|
|
5696
|
-
|
|
5521
|
+
this.#LogErrorMessage(chalk.red(`ObservabilityRESTAPISubscriber:#AddKeepAlive(): Error response: [${JSON.stringify(error)}]`));
|
|
5522
|
+
this.#RemoveKeepAlive(subscription);
|
|
5697
5523
|
}
|
|
5698
|
-
}, timeout);
|
|
5699
|
-
};
|
|
5700
|
-
AddKeepAlive_fn = function(subscription) {
|
|
5701
|
-
__privateMethod(this, _ObservabilityRESTAPISubscriber_instances, RemoveKeepAlive_fn).call(this, subscription);
|
|
5702
|
-
const socketSubscribeKeepAlive = {
|
|
5703
|
-
id: subscription.subscriptionKey.id
|
|
5704
5524
|
};
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5525
|
+
#SetupTimeout(socketSubscribeKeepAlive, subscription, timeout) {
|
|
5526
|
+
return setTimeout(async () => {
|
|
5527
|
+
try {
|
|
5528
|
+
const start = performance.now();
|
|
5529
|
+
await this.#GetData(subscription);
|
|
5530
|
+
if (socketSubscribeKeepAlive.timeout) {
|
|
5531
|
+
const end = performance.now();
|
|
5532
|
+
const diff = end - start;
|
|
5533
|
+
let timeoutDuration = this.#options.keepAlive - diff;
|
|
5534
|
+
if (timeoutDuration < 500) {
|
|
5535
|
+
timeoutDuration = 500;
|
|
5536
|
+
}
|
|
5537
|
+
socketSubscribeKeepAlive.timeout = this.#SetupTimeout(socketSubscribeKeepAlive, subscription, timeoutDuration);
|
|
5538
|
+
} else {
|
|
5539
|
+
this.#LogDebugMessage(chalk.yellow(`Subscription removed: [${socketSubscribeKeepAlive.id}]. Processing terminate.`));
|
|
5540
|
+
}
|
|
5541
|
+
} catch (error) {
|
|
5542
|
+
this.#LogErrorMessage(chalk.red(`ObservabilityRESTAPISubscriber:#AddKeepAlive(): Error response: [${JSON.stringify(error)}]`));
|
|
5543
|
+
this.#RemoveKeepAlive(subscription);
|
|
5544
|
+
}
|
|
5545
|
+
}, timeout);
|
|
5715
5546
|
}
|
|
5716
|
-
|
|
5547
|
+
#AddKeepAlive(subscription) {
|
|
5548
|
+
this.#RemoveKeepAlive(subscription);
|
|
5549
|
+
const socketSubscribeKeepAlive = {
|
|
5550
|
+
id: subscription.subscriptionKey.id
|
|
5551
|
+
};
|
|
5552
|
+
socketSubscribeKeepAlive.timeout = this.#SetupTimeout(socketSubscribeKeepAlive, subscription, this.#options.keepAlive);
|
|
5553
|
+
this.#socketSubscribeKeepAlive[subscription.subscriptionKey.id] = socketSubscribeKeepAlive;
|
|
5554
|
+
this.#GetData(subscription);
|
|
5555
|
+
}
|
|
5556
|
+
#RemoveKeepAlive(subscription) {
|
|
5557
|
+
if (this.#socketSubscribeKeepAlive[subscription.subscriptionKey.id]) {
|
|
5558
|
+
this.#LogDebugMessage(chalk.gray(`ObservabilityRESTAPISubscriber:#RemoveKeepAlive(): subscriptionKey: [${subscription.subscriptionKey.id}]`));
|
|
5559
|
+
clearTimeout(this.#socketSubscribeKeepAlive[subscription.subscriptionKey.id].timeout);
|
|
5560
|
+
delete this.#socketSubscribeKeepAlive[subscription.subscriptionKey.id].timeout;
|
|
5561
|
+
delete this.#socketSubscribeKeepAlive[subscription.subscriptionKey.id];
|
|
5562
|
+
}
|
|
5563
|
+
}
|
|
5564
|
+
}
|
|
5717
5565
|
const byteToHex = [];
|
|
5718
5566
|
for (let i = 0; i < 256; ++i) {
|
|
5719
5567
|
byteToHex.push((i + 256).toString(16).slice(1));
|
|
@@ -5734,13 +5582,9 @@ function rng() {
|
|
|
5734
5582
|
}
|
|
5735
5583
|
const randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
5736
5584
|
const native = { randomUUID };
|
|
5737
|
-
function
|
|
5738
|
-
var _a2;
|
|
5739
|
-
if (native.randomUUID && true && !options) {
|
|
5740
|
-
return native.randomUUID();
|
|
5741
|
-
}
|
|
5585
|
+
function _v4(options, buf, offset) {
|
|
5742
5586
|
options = options || {};
|
|
5743
|
-
const rnds = options.random ??
|
|
5587
|
+
const rnds = options.random ?? options.rng?.() ?? rng();
|
|
5744
5588
|
if (rnds.length < 16) {
|
|
5745
5589
|
throw new Error("Random bytes length must be >= 16");
|
|
5746
5590
|
}
|
|
@@ -5748,6 +5592,12 @@ function v4(options, buf, offset) {
|
|
|
5748
5592
|
rnds[8] = rnds[8] & 63 | 128;
|
|
5749
5593
|
return unsafeStringify(rnds);
|
|
5750
5594
|
}
|
|
5595
|
+
function v4(options, buf, offset) {
|
|
5596
|
+
if (native.randomUUID && true && !options) {
|
|
5597
|
+
return native.randomUUID();
|
|
5598
|
+
}
|
|
5599
|
+
return _v4(options);
|
|
5600
|
+
}
|
|
5751
5601
|
var messageStatus = /* @__PURE__ */ ((messageStatus2) => {
|
|
5752
5602
|
messageStatus2["INPROGRESS"] = "INPROGRESS";
|
|
5753
5603
|
messageStatus2["SUCCESS"] = "SUCCESS";
|
|
@@ -5764,68 +5614,73 @@ var messageStatusResponse = /* @__PURE__ */ ((messageStatusResponse2) => {
|
|
|
5764
5614
|
return messageStatusResponse2;
|
|
5765
5615
|
})(messageStatusResponse || {});
|
|
5766
5616
|
class SocketIoMessageSender {
|
|
5617
|
+
#messageWithAckPayloadRecords = {};
|
|
5618
|
+
#socket;
|
|
5619
|
+
#maxReties = 3;
|
|
5620
|
+
//@@
|
|
5621
|
+
#timeoutValue = 5e3;
|
|
5622
|
+
//@@
|
|
5623
|
+
#options;
|
|
5624
|
+
#LogDebugMessage(message) {
|
|
5625
|
+
this.#options.logger.debug(message);
|
|
5626
|
+
}
|
|
5767
5627
|
constructor(options) {
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
__privateAdd(this, _socket);
|
|
5771
|
-
__privateAdd(this, _maxReties, 3);
|
|
5772
|
-
//@@
|
|
5773
|
-
__privateAdd(this, _timeoutValue, 5e3);
|
|
5774
|
-
//@@
|
|
5775
|
-
__privateAdd(this, _options3);
|
|
5776
|
-
__privateSet(this, _options3, options);
|
|
5777
|
-
__privateSet(this, _socket, options.socket);
|
|
5628
|
+
this.#options = options;
|
|
5629
|
+
this.#socket = options.socket;
|
|
5778
5630
|
}
|
|
5779
5631
|
get socket() {
|
|
5780
|
-
return
|
|
5632
|
+
return this.#socket;
|
|
5781
5633
|
}
|
|
5782
5634
|
set socket(socket) {
|
|
5783
|
-
|
|
5784
|
-
|
|
5635
|
+
this.#LogDebugMessage(chalk.cyan(`SocketIoMessageSender:set socket(): new socket assigned`));
|
|
5636
|
+
this.#socket = socket;
|
|
5785
5637
|
}
|
|
5786
5638
|
AckListener(message, payload) {
|
|
5787
5639
|
if (message.subscriptionKey.id.localeCompare(payload.id) === 0) {
|
|
5788
5640
|
clearTimeout(message.timeoutId);
|
|
5789
5641
|
delete message.timeoutId;
|
|
5790
|
-
|
|
5642
|
+
this.#socket.off(this.#GetSubscribeKeepAliveAckEventName(message.eventName, message.subscriptionKey), message.BoundAckListenerCallback);
|
|
5791
5643
|
message.endTime = performance.now();
|
|
5792
5644
|
message.duration = message.endTime - message.startTime;
|
|
5793
5645
|
message.status = "SUCCESS";
|
|
5794
5646
|
message.subscriptionKeyResponse = payload;
|
|
5795
|
-
delete
|
|
5796
|
-
|
|
5647
|
+
delete this.#messageWithAckPayloadRecords[message.id];
|
|
5648
|
+
this.#LogDebugMessage(chalk.grey(`SocketIoMessageSender:AckListener(): ack received, event: [${message.eventName}], subscriptionKey: [${message.subscriptionKey.id}]`));
|
|
5797
5649
|
message.resolve(message);
|
|
5798
5650
|
}
|
|
5799
5651
|
}
|
|
5800
5652
|
ResponseTimout(message) {
|
|
5801
|
-
|
|
5653
|
+
this.#LogDebugMessage(chalk.magenta(`SocketIoMessageSender:ResponseTimout(): timeout reached: [${this.#timeoutValue}], event: [${message.eventName}], subscriptionKey: [${message.subscriptionKey.id}]`));
|
|
5802
5654
|
delete message.timeoutId;
|
|
5803
|
-
|
|
5655
|
+
this.#socket.off(this.#GetSubscribeKeepAliveAckEventName(message.eventName, message.subscriptionKey), message.BoundAckListenerCallback);
|
|
5804
5656
|
message.endTime = performance.now();
|
|
5805
|
-
if (message.retryCount >=
|
|
5657
|
+
if (message.retryCount >= this.#maxReties) {
|
|
5806
5658
|
message.status = "FAIL";
|
|
5807
|
-
|
|
5808
|
-
delete
|
|
5659
|
+
this.#LogDebugMessage(chalk.red(`SocketIoMessageSender:ResponseTimout(): timeout reached after ${this.#maxReties} retries, event: [${message.eventName}], subscriptionKey: [${message.subscriptionKey.id}]`));
|
|
5660
|
+
delete this.#messageWithAckPayloadRecords[message.id];
|
|
5809
5661
|
message.reject(message);
|
|
5810
5662
|
return;
|
|
5811
5663
|
}
|
|
5812
5664
|
message.status = "INRETRY";
|
|
5813
5665
|
message.retryCount++;
|
|
5814
|
-
|
|
5666
|
+
this.#LogDebugMessage(chalk.magenta(`SocketIoMessageSender:ResponseTimout(): timeout reached, retrying. Retries: [${message.retryCount}], event: [${message.eventName}], subscriptionKey: [${message.subscriptionKey.id}]`));
|
|
5815
5667
|
this.SendMessage(message);
|
|
5816
5668
|
}
|
|
5669
|
+
#GetSubscribeKeepAliveAckEventName(eventName, subscriptionKey) {
|
|
5670
|
+
return `${eventName}Ack_${subscriptionKey.id}`;
|
|
5671
|
+
}
|
|
5817
5672
|
SendMessage(message) {
|
|
5818
5673
|
message.startTime = performance.now();
|
|
5819
5674
|
message.timeoutId = setTimeout(() => {
|
|
5820
5675
|
this.ResponseTimout(message);
|
|
5821
|
-
},
|
|
5676
|
+
}, this.#timeoutValue);
|
|
5822
5677
|
const AckListenerCallback = (payload) => {
|
|
5823
5678
|
this.AckListener(message, payload);
|
|
5824
5679
|
};
|
|
5825
5680
|
message.BoundAckListenerCallback = AckListenerCallback.bind(this);
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5681
|
+
this.#socket.on(this.#GetSubscribeKeepAliveAckEventName(message.eventName, message.subscriptionKey), message.BoundAckListenerCallback);
|
|
5682
|
+
this.#LogDebugMessage(chalk.gray(`SocketIoMessageSender:SendMessage(): event: [${message.eventName}], subscriptionKey: [${message.subscriptionKey.id}]`));
|
|
5683
|
+
this.#socket.emit(message.eventName, message.subscriptionKey);
|
|
5829
5684
|
}
|
|
5830
5685
|
SendMessageWithAck(eventName, subscriptionKey) {
|
|
5831
5686
|
const promise = new Promise((resolve, reject) => {
|
|
@@ -5839,82 +5694,75 @@ class SocketIoMessageSender {
|
|
|
5839
5694
|
resolve,
|
|
5840
5695
|
reject
|
|
5841
5696
|
};
|
|
5842
|
-
|
|
5697
|
+
this.#messageWithAckPayloadRecords[message.id] = message;
|
|
5843
5698
|
this.SendMessage(message);
|
|
5844
5699
|
});
|
|
5845
5700
|
return promise;
|
|
5846
5701
|
}
|
|
5847
5702
|
KillMessageInFlight(subscriptionKey) {
|
|
5848
5703
|
const killIds = [];
|
|
5849
|
-
for (const [, message] of Object.entries(
|
|
5704
|
+
for (const [, message] of Object.entries(this.#messageWithAckPayloadRecords)) {
|
|
5850
5705
|
if (message.subscriptionKey.id.localeCompare(subscriptionKey.id) === 0) {
|
|
5851
|
-
|
|
5706
|
+
this.#LogDebugMessage(chalk.blue(`SocketIoMessageSender:KillMessageInFlight(): event: [${message.eventName}], subscriptionKey: [${message.subscriptionKey.id}]`));
|
|
5852
5707
|
clearTimeout(message.timeoutId);
|
|
5853
5708
|
delete message.timeoutId;
|
|
5854
|
-
|
|
5709
|
+
this.#socket.off(this.#GetSubscribeKeepAliveAckEventName(message.eventName, message.subscriptionKey), message.BoundAckListenerCallback);
|
|
5855
5710
|
killIds.push(message.id);
|
|
5856
5711
|
message.status = "KILLED";
|
|
5857
5712
|
message.reject(message);
|
|
5858
5713
|
}
|
|
5859
5714
|
}
|
|
5860
5715
|
killIds.forEach((id) => {
|
|
5861
|
-
delete
|
|
5716
|
+
delete this.#messageWithAckPayloadRecords[id];
|
|
5862
5717
|
});
|
|
5863
5718
|
}
|
|
5864
5719
|
}
|
|
5865
|
-
_messageWithAckPayloadRecords = new WeakMap();
|
|
5866
|
-
_socket = new WeakMap();
|
|
5867
|
-
_maxReties = new WeakMap();
|
|
5868
|
-
_timeoutValue = new WeakMap();
|
|
5869
|
-
_options3 = new WeakMap();
|
|
5870
|
-
_SocketIoMessageSender_instances = new WeakSet();
|
|
5871
|
-
LogDebugMessage_fn2 = function(message) {
|
|
5872
|
-
__privateGet(this, _options3).logger.debug(message);
|
|
5873
|
-
};
|
|
5874
|
-
GetSubscribeKeepAliveAckEventName_fn = function(eventName, subscriptionKey) {
|
|
5875
|
-
return `${eventName}Ack_${subscriptionKey.id}`;
|
|
5876
|
-
};
|
|
5877
5720
|
class ObservabilitySocketIOSubscriber {
|
|
5721
|
+
#socketSubscribeKeepAlive = {};
|
|
5722
|
+
#socket;
|
|
5723
|
+
#options;
|
|
5724
|
+
#socketIoMessageSender;
|
|
5725
|
+
// This is required becuase each call to .bind create a new replica bound function - so we need the same instance for on/off event bindings.
|
|
5726
|
+
KeepAliveAckBoundFunction;
|
|
5727
|
+
#LogDebugMessage(message) {
|
|
5728
|
+
this.#options.logger.debug(message);
|
|
5729
|
+
}
|
|
5730
|
+
#LogErrorMessage(message) {
|
|
5731
|
+
this.#options.logger.error(message);
|
|
5732
|
+
}
|
|
5878
5733
|
constructor(options) {
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
__publicField(this, "KeepAliveAckBoundFunction");
|
|
5886
|
-
__privateSet(this, _options4, options);
|
|
5887
|
-
__privateSet(this, _socket2, options.socket);
|
|
5888
|
-
__privateSet(this, _socketIoMessageSender, new SocketIoMessageSender({
|
|
5889
|
-
socket: __privateGet(this, _socket2),
|
|
5890
|
-
logger: __privateGet(this, _options4).logger
|
|
5891
|
-
}));
|
|
5734
|
+
this.#options = options;
|
|
5735
|
+
this.#socket = options.socket;
|
|
5736
|
+
this.#socketIoMessageSender = new SocketIoMessageSender({
|
|
5737
|
+
socket: this.#socket,
|
|
5738
|
+
logger: this.#options.logger
|
|
5739
|
+
});
|
|
5892
5740
|
}
|
|
5893
5741
|
get socket() {
|
|
5894
|
-
return
|
|
5742
|
+
return this.#socket;
|
|
5895
5743
|
}
|
|
5896
5744
|
set socket(socket) {
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5745
|
+
this.#LogDebugMessage(chalk.cyan(`ObservabilitySocketIOSubscriber:set socket(): new socket assigned`));
|
|
5746
|
+
this.#socket = socket;
|
|
5747
|
+
this.#socketIoMessageSender.socket = socket;
|
|
5900
5748
|
}
|
|
5901
5749
|
SubscribeOne(subscription) {
|
|
5902
5750
|
this.Subscribe([subscription]);
|
|
5903
5751
|
}
|
|
5904
5752
|
async Subscribe(subscriptions) {
|
|
5905
|
-
const socket =
|
|
5753
|
+
const socket = this.#socket;
|
|
5906
5754
|
subscriptions.map(async (subId) => {
|
|
5907
|
-
|
|
5908
|
-
|
|
5755
|
+
this.#RemoveKeepAlive(subId);
|
|
5756
|
+
this.#LogDebugMessage(chalk.yellow(`ObservabilitySocketIOSubscriber:Subscribe(): Sending subscribe: subscriptionKey: [${subId.subscriptionKey.id}]`));
|
|
5909
5757
|
try {
|
|
5910
|
-
const retVal = await
|
|
5911
|
-
|
|
5912
|
-
|
|
5758
|
+
const retVal = await this.#socketIoMessageSender.SendMessageWithAck("subscribe", subId.subscriptionKey);
|
|
5759
|
+
this.#LogDebugMessage(chalk.green(`ObservabilitySocketIOSubscriber:Subscribe(): SendMessageWithAck response: [${JSON.stringify(retVal)}]`));
|
|
5760
|
+
this.#AddKeepAlive(socket, subId);
|
|
5913
5761
|
socket.on(GetSocketIOSubscriptionKey(subId.subscriptionKey), subId.cb);
|
|
5914
5762
|
} catch (error) {
|
|
5915
|
-
|
|
5763
|
+
this.#LogErrorMessage(chalk.red(`ObservabilitySocketIOSubscriber:Subscribe(): Error: response: [${JSON.stringify(error)}]`));
|
|
5916
5764
|
socket.off(GetSocketIOSubscriptionKey(subId.subscriptionKey), subId.cb);
|
|
5917
|
-
|
|
5765
|
+
this.#RemoveKeepAlive(subId);
|
|
5918
5766
|
}
|
|
5919
5767
|
});
|
|
5920
5768
|
}
|
|
@@ -5922,20 +5770,45 @@ class ObservabilitySocketIOSubscriber {
|
|
|
5922
5770
|
this.UnSubscribe([subscription]);
|
|
5923
5771
|
}
|
|
5924
5772
|
UnSubscribe(subscriptions) {
|
|
5925
|
-
const socket =
|
|
5773
|
+
const socket = this.#socket;
|
|
5926
5774
|
subscriptions.map(async (subId) => {
|
|
5927
5775
|
socket.off(GetSocketIOSubscriptionKey(subId.subscriptionKey), subId.cb);
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5776
|
+
this.#RemoveKeepAlive(subId);
|
|
5777
|
+
this.#socketIoMessageSender.KillMessageInFlight(subId.subscriptionKey);
|
|
5778
|
+
this.#LogDebugMessage(chalk.yellow(`ObservabilitySocketIOSubscriber:UnSubscribe(): Sending unsubscribe: subscriptionKey: [${subId.subscriptionKey.id}]`));
|
|
5931
5779
|
try {
|
|
5932
|
-
const retVal = await
|
|
5933
|
-
|
|
5780
|
+
const retVal = await this.#socketIoMessageSender.SendMessageWithAck("unsubscribe", subId.subscriptionKey);
|
|
5781
|
+
this.#LogDebugMessage(chalk.green(`ObservabilitySocketIOSubscriber:UnSubscribe(): SendMessageWithAck response: [${JSON.stringify(retVal)}]`));
|
|
5934
5782
|
} catch (error) {
|
|
5935
|
-
|
|
5783
|
+
this.#LogErrorMessage(chalk.red(`ObservabilitySocketIOSubscriber:UnSubscribe(): Error response: [${JSON.stringify(error)}]`));
|
|
5936
5784
|
}
|
|
5937
5785
|
});
|
|
5938
5786
|
}
|
|
5787
|
+
#AddKeepAlive(socket, subscription) {
|
|
5788
|
+
this.#RemoveKeepAlive(subscription);
|
|
5789
|
+
this.#socketSubscribeKeepAlive[subscription.subscriptionKey.id] = {
|
|
5790
|
+
id: subscription.subscriptionKey.id,
|
|
5791
|
+
timeout: setTimeout(async () => {
|
|
5792
|
+
this.#LogDebugMessage(chalk.yellow(`ObservabilitySocketIOSubscriber:#AddKeepAlive:timeoutCheck(): Sending keepAlive: subscriptionKey: [${subscription.subscriptionKey.id}]`));
|
|
5793
|
+
try {
|
|
5794
|
+
const retVal = await this.#socketIoMessageSender.SendMessageWithAck("subscribeKeepAlive", subscription.subscriptionKey);
|
|
5795
|
+
this.#LogDebugMessage(chalk.green(`ObservabilitySocketIOSubscriber:#AddKeepAlive(): SendMessageWithAck response: [${JSON.stringify(retVal)}]`));
|
|
5796
|
+
this.#AddKeepAlive(socket, subscription);
|
|
5797
|
+
} catch (error) {
|
|
5798
|
+
this.#LogErrorMessage(chalk.red(`ObservabilitySocketIOSubscriber:#AddKeepAlive(): Error response: [${JSON.stringify(error)}]`));
|
|
5799
|
+
socket.off(GetSocketIOSubscriptionKey(subscription.subscriptionKey), subscription.cb);
|
|
5800
|
+
this.#RemoveKeepAlive(subscription);
|
|
5801
|
+
}
|
|
5802
|
+
}, this.#options.keepAlive)
|
|
5803
|
+
};
|
|
5804
|
+
}
|
|
5805
|
+
#RemoveKeepAlive(subscription) {
|
|
5806
|
+
if (this.#socketSubscribeKeepAlive[subscription.subscriptionKey.id]) {
|
|
5807
|
+
this.#LogDebugMessage(chalk.gray(`ObservabilitySocketIOSubscriber:#RemoveKeepAlive(): subscriptionKey: [${subscription.subscriptionKey.id}]`));
|
|
5808
|
+
clearTimeout(this.#socketSubscribeKeepAlive[subscription.subscriptionKey.id].timeout);
|
|
5809
|
+
delete this.#socketSubscribeKeepAlive[subscription.subscriptionKey.id];
|
|
5810
|
+
}
|
|
5811
|
+
}
|
|
5939
5812
|
/*
|
|
5940
5813
|
override SocketIOConnect(socket: Socket<ServerToClientEvents, ClientToServerEvents>): void {
|
|
5941
5814
|
if (this.#observabilitySocketIOSubscriber instanceof ObservabilitySocketIOSubscriber) {
|
|
@@ -5950,124 +5823,89 @@ class ObservabilitySocketIOSubscriber {
|
|
|
5950
5823
|
}
|
|
5951
5824
|
*/
|
|
5952
5825
|
}
|
|
5953
|
-
_socketSubscribeKeepAlive2 = new WeakMap();
|
|
5954
|
-
_socket2 = new WeakMap();
|
|
5955
|
-
_options4 = new WeakMap();
|
|
5956
|
-
_socketIoMessageSender = new WeakMap();
|
|
5957
|
-
_ObservabilitySocketIOSubscriber_instances = new WeakSet();
|
|
5958
|
-
LogDebugMessage_fn3 = function(message) {
|
|
5959
|
-
__privateGet(this, _options4).logger.debug(message);
|
|
5960
|
-
};
|
|
5961
|
-
LogErrorMessage_fn2 = function(message) {
|
|
5962
|
-
__privateGet(this, _options4).logger.error(message);
|
|
5963
|
-
};
|
|
5964
|
-
AddKeepAlive_fn2 = function(socket, subscription) {
|
|
5965
|
-
__privateMethod(this, _ObservabilitySocketIOSubscriber_instances, RemoveKeepAlive_fn2).call(this, subscription);
|
|
5966
|
-
__privateGet(this, _socketSubscribeKeepAlive2)[subscription.subscriptionKey.id] = {
|
|
5967
|
-
id: subscription.subscriptionKey.id,
|
|
5968
|
-
timeout: setTimeout(async () => {
|
|
5969
|
-
__privateMethod(this, _ObservabilitySocketIOSubscriber_instances, LogDebugMessage_fn3).call(this, chalk.yellow(`ObservabilitySocketIOSubscriber:#AddKeepAlive:timeoutCheck(): Sending keepAlive: subscriptionKey: [${subscription.subscriptionKey.id}]`));
|
|
5970
|
-
try {
|
|
5971
|
-
const retVal = await __privateGet(this, _socketIoMessageSender).SendMessageWithAck("subscribeKeepAlive", subscription.subscriptionKey);
|
|
5972
|
-
__privateMethod(this, _ObservabilitySocketIOSubscriber_instances, LogDebugMessage_fn3).call(this, chalk.green(`ObservabilitySocketIOSubscriber:#AddKeepAlive(): SendMessageWithAck response: [${JSON.stringify(retVal)}]`));
|
|
5973
|
-
__privateMethod(this, _ObservabilitySocketIOSubscriber_instances, AddKeepAlive_fn2).call(this, socket, subscription);
|
|
5974
|
-
} catch (error) {
|
|
5975
|
-
__privateMethod(this, _ObservabilitySocketIOSubscriber_instances, LogErrorMessage_fn2).call(this, chalk.red(`ObservabilitySocketIOSubscriber:#AddKeepAlive(): Error response: [${JSON.stringify(error)}]`));
|
|
5976
|
-
socket.off(GetSocketIOSubscriptionKey(subscription.subscriptionKey), subscription.cb);
|
|
5977
|
-
__privateMethod(this, _ObservabilitySocketIOSubscriber_instances, RemoveKeepAlive_fn2).call(this, subscription);
|
|
5978
|
-
}
|
|
5979
|
-
}, __privateGet(this, _options4).keepAlive)
|
|
5980
|
-
};
|
|
5981
|
-
};
|
|
5982
|
-
RemoveKeepAlive_fn2 = function(subscription) {
|
|
5983
|
-
if (__privateGet(this, _socketSubscribeKeepAlive2)[subscription.subscriptionKey.id]) {
|
|
5984
|
-
__privateMethod(this, _ObservabilitySocketIOSubscriber_instances, LogDebugMessage_fn3).call(this, chalk.gray(`ObservabilitySocketIOSubscriber:#RemoveKeepAlive(): subscriptionKey: [${subscription.subscriptionKey.id}]`));
|
|
5985
|
-
clearTimeout(__privateGet(this, _socketSubscribeKeepAlive2)[subscription.subscriptionKey.id].timeout);
|
|
5986
|
-
delete __privateGet(this, _socketSubscribeKeepAlive2)[subscription.subscriptionKey.id];
|
|
5987
|
-
}
|
|
5988
|
-
};
|
|
5989
5826
|
class ObservabilitySubscriptionManager {
|
|
5827
|
+
#observabilitySocketIOSubscriber = null;
|
|
5828
|
+
#subscriptions = [];
|
|
5829
|
+
#kafkaHelper;
|
|
5830
|
+
#serviceModel = {};
|
|
5831
|
+
#agentModel = {};
|
|
5832
|
+
#lambdaModel = {};
|
|
5833
|
+
#options;
|
|
5834
|
+
#LogDebugMessage(message) {
|
|
5835
|
+
this.#options.logger.debug(message);
|
|
5836
|
+
}
|
|
5837
|
+
#LogErrorMessage(message) {
|
|
5838
|
+
this.#options.logger.error(message);
|
|
5839
|
+
}
|
|
5990
5840
|
constructor(options) {
|
|
5991
|
-
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
__privateAdd(this, _serviceModel, {});
|
|
5996
|
-
__privateAdd(this, _agentModel, {});
|
|
5997
|
-
__privateAdd(this, _lambdaModel, {});
|
|
5998
|
-
__privateAdd(this, _options5);
|
|
5999
|
-
__privateSet(this, _options5, options);
|
|
6000
|
-
__privateSet(this, _kafkaHelper, new KafkaHelper({
|
|
6001
|
-
maxLogLength: __privateGet(this, _options5).maxLogLength
|
|
6002
|
-
}));
|
|
5841
|
+
this.#options = options;
|
|
5842
|
+
this.#kafkaHelper = new KafkaHelper({
|
|
5843
|
+
maxLogLength: this.#options.maxLogLength
|
|
5844
|
+
});
|
|
6003
5845
|
}
|
|
6004
5846
|
get observabilitySocketIOSubscriber() {
|
|
6005
|
-
return
|
|
5847
|
+
return this.#observabilitySocketIOSubscriber;
|
|
6006
5848
|
}
|
|
6007
5849
|
set observabilitySocketIOSubscriber(observabilitySocketIOSubscriber) {
|
|
6008
|
-
|
|
5850
|
+
this.#observabilitySocketIOSubscriber = observabilitySocketIOSubscriber;
|
|
6009
5851
|
}
|
|
6010
5852
|
get subscriptions() {
|
|
6011
|
-
return
|
|
5853
|
+
return this.#subscriptions;
|
|
6012
5854
|
}
|
|
6013
5855
|
set subscriptions(subscriptions) {
|
|
6014
|
-
|
|
5856
|
+
this.#subscriptions = subscriptions;
|
|
6015
5857
|
}
|
|
6016
5858
|
get serviceModel() {
|
|
6017
|
-
return
|
|
5859
|
+
return this.#serviceModel;
|
|
6018
5860
|
}
|
|
6019
5861
|
get agentModel() {
|
|
6020
|
-
return
|
|
5862
|
+
return this.#agentModel;
|
|
6021
5863
|
}
|
|
6022
5864
|
get lambdaModel() {
|
|
6023
|
-
return
|
|
5865
|
+
return this.#lambdaModel;
|
|
6024
5866
|
}
|
|
6025
5867
|
AddSubscriptions(subscriptions) {
|
|
6026
|
-
var _a2;
|
|
6027
5868
|
const subscriptionsToAdd = [];
|
|
6028
5869
|
subscriptions.map((subscription) => {
|
|
6029
5870
|
const retVal = this.subscriptions.find((v) => v.subscriptionKey.id.localeCompare(subscription.subscriptionKey.id) === 0);
|
|
6030
5871
|
if (retVal) {
|
|
6031
|
-
|
|
5872
|
+
this.#LogDebugMessage(chalk.magenta(`AddSubscription(): Subscription: [${retVal.subscriptionKey.id}] already exists - ignoring.`));
|
|
6032
5873
|
} else {
|
|
6033
5874
|
subscriptionsToAdd.push(subscription);
|
|
6034
5875
|
}
|
|
6035
5876
|
});
|
|
6036
5877
|
if (subscriptionsToAdd.length > 0) {
|
|
6037
5878
|
subscriptionsToAdd.map((s) => this.subscriptions.push(s));
|
|
6038
|
-
|
|
5879
|
+
this.#observabilitySocketIOSubscriber?.Subscribe(subscriptionsToAdd);
|
|
6039
5880
|
} else {
|
|
6040
|
-
|
|
5881
|
+
this.#LogDebugMessage(chalk.magenta(`AddSubscription(): No valid subscriptions to subscribe.`));
|
|
6041
5882
|
}
|
|
6042
5883
|
}
|
|
6043
5884
|
RemoveSubscriptionsByKey(keyToFind) {
|
|
6044
|
-
var _a2;
|
|
6045
5885
|
const newSubscriptions = [];
|
|
6046
5886
|
for (let i = 0; i < this.subscriptions.length; i++) {
|
|
6047
|
-
if (
|
|
6048
|
-
if (
|
|
6049
|
-
|
|
5887
|
+
if (this.subscriptions[i].subscriptionKey.key?.localeCompare(keyToFind) === 0) {
|
|
5888
|
+
if (this.#observabilitySocketIOSubscriber) {
|
|
5889
|
+
this.#observabilitySocketIOSubscriber.UnSubscribeOne(this.subscriptions[i]);
|
|
6050
5890
|
}
|
|
6051
5891
|
} else {
|
|
6052
5892
|
newSubscriptions.push(this.subscriptions[i]);
|
|
6053
5893
|
}
|
|
6054
5894
|
}
|
|
6055
|
-
|
|
5895
|
+
this.#subscriptions = newSubscriptions;
|
|
6056
5896
|
}
|
|
6057
5897
|
FindSubscriptionByKey(keyToFind) {
|
|
6058
|
-
var _a2;
|
|
6059
5898
|
for (let i = 0; i < this.subscriptions.length; i++) {
|
|
6060
|
-
if (
|
|
5899
|
+
if (this.subscriptions[i].subscriptionKey.key?.localeCompare(keyToFind) === 0) {
|
|
6061
5900
|
return this.subscriptions[i];
|
|
6062
5901
|
}
|
|
6063
5902
|
}
|
|
6064
5903
|
return void 0;
|
|
6065
5904
|
}
|
|
6066
5905
|
FindSubscriptionByKeyAndSubKey(keyToFind, subKeyToFind) {
|
|
6067
|
-
var _a2, _b;
|
|
6068
5906
|
for (let i = 0; i < this.subscriptions.length; i++) {
|
|
6069
|
-
if (
|
|
6070
|
-
if (
|
|
5907
|
+
if (this.subscriptions[i].subscriptionKey.key?.localeCompare(keyToFind) === 0) {
|
|
5908
|
+
if (this.subscriptions[i].subscriptionKey.subkey?.localeCompare(subKeyToFind) === 0) {
|
|
6071
5909
|
return this.subscriptions[i];
|
|
6072
5910
|
}
|
|
6073
5911
|
}
|
|
@@ -6075,13 +5913,13 @@ class ObservabilitySubscriptionManager {
|
|
|
6075
5913
|
return void 0;
|
|
6076
5914
|
}
|
|
6077
5915
|
Start() {
|
|
6078
|
-
if (
|
|
6079
|
-
|
|
5916
|
+
if (this.#observabilitySocketIOSubscriber) {
|
|
5917
|
+
this.#observabilitySocketIOSubscriber.Subscribe(this.subscriptions);
|
|
6080
5918
|
}
|
|
6081
5919
|
}
|
|
6082
5920
|
Stop() {
|
|
6083
|
-
if (
|
|
6084
|
-
|
|
5921
|
+
if (this.#observabilitySocketIOSubscriber) {
|
|
5922
|
+
this.#observabilitySocketIOSubscriber.UnSubscribe(this.subscriptions);
|
|
6085
5923
|
}
|
|
6086
5924
|
}
|
|
6087
5925
|
TransformSubscriptionPayloadCallback(subscriptionPayload, subscribeToKafka) {
|
|
@@ -6131,26 +5969,26 @@ class ObservabilitySubscriptionManager {
|
|
|
6131
5969
|
// /
|
|
6132
5970
|
CreateModelAllServicesCombined(subscriptionPayload, subscribeToKafka) {
|
|
6133
5971
|
try {
|
|
6134
|
-
|
|
5972
|
+
this.#serviceModel = {};
|
|
6135
5973
|
if (subscriptionPayload.subscriptionKey.topic.localeCompare(SubscriptionTopic.AllServicesCombined.toString()) === 0) {
|
|
6136
|
-
|
|
6137
|
-
if (
|
|
6138
|
-
|
|
5974
|
+
this.#serviceModel["STS-Service"] = ObservabilityModelUtils.GetModelForService("STS-Service", subscriptionPayload.data, subscribeToKafka, this.#options.logger);
|
|
5975
|
+
if (this.#serviceModel["STS-Service"] === null) {
|
|
5976
|
+
this.#LogDebugMessage(chalk.red(`CreateModelAllServicesCombined():Error: GetModelForService() returned null`));
|
|
6139
5977
|
}
|
|
6140
5978
|
}
|
|
6141
5979
|
} catch (error) {
|
|
6142
|
-
|
|
5980
|
+
this.#LogErrorMessage(error);
|
|
6143
5981
|
return;
|
|
6144
5982
|
}
|
|
6145
5983
|
}
|
|
6146
5984
|
// /serviceId
|
|
6147
5985
|
CreateModelServices(subscriptionPayload, subscribeToKafka) {
|
|
6148
5986
|
try {
|
|
6149
|
-
|
|
5987
|
+
this.#serviceModel = {};
|
|
6150
5988
|
for (const [serviceId, serviceTelemetry] of Object.entries(subscriptionPayload.data)) {
|
|
6151
|
-
|
|
6152
|
-
if (
|
|
6153
|
-
|
|
5989
|
+
this.#serviceModel[serviceId] = ObservabilityModelUtils.GetModelForService(serviceId, serviceTelemetry, subscribeToKafka, this.#options.logger);
|
|
5990
|
+
if (this.#serviceModel[serviceId] === null) {
|
|
5991
|
+
this.#LogDebugMessage(chalk.red(`CreateModelServices():Error: GetModelForService() returned null`));
|
|
6154
5992
|
}
|
|
6155
5993
|
}
|
|
6156
5994
|
} catch (error) {
|
|
@@ -6160,16 +5998,16 @@ class ObservabilitySubscriptionManager {
|
|
|
6160
5998
|
// /serviceId/serviceInstanceId
|
|
6161
5999
|
CreateModelServiceInstances(subscriptionPayload, subscribeToKafka) {
|
|
6162
6000
|
try {
|
|
6163
|
-
|
|
6001
|
+
this.#serviceModel = {};
|
|
6164
6002
|
for (const [serviceId, service] of Object.entries(subscriptionPayload.data)) {
|
|
6165
6003
|
for (const [serviceInstanceId, serviceInstanceTelemetry] of Object.entries(service)) {
|
|
6166
6004
|
const kafkaTopic = `${KAFKA_PREFIX}_${serviceInstanceId}`.replace(/@/g, "_").replace(/\|/g, "_");
|
|
6167
6005
|
if (serviceInstanceTelemetry.cpu && serviceInstanceTelemetry.cpu > 0) {
|
|
6168
|
-
|
|
6169
|
-
if (
|
|
6170
|
-
|
|
6006
|
+
this.#serviceModel[serviceInstanceId] = ObservabilityModelUtils.GetModelForService(serviceInstanceId, serviceInstanceTelemetry, subscribeToKafka, this.#options.logger);
|
|
6007
|
+
if (this.#serviceModel[serviceInstanceId] !== null) {
|
|
6008
|
+
this.#serviceModel[serviceInstanceId].options = { serviceId };
|
|
6171
6009
|
if (subscribeToKafka) {
|
|
6172
|
-
|
|
6010
|
+
this.#kafkaHelper.GetKafkaLogData(kafkaTopic, this.#serviceModel[serviceInstanceId]);
|
|
6173
6011
|
if (!this.FindSubscriptionByKey(kafkaTopic)) {
|
|
6174
6012
|
this.AddSubscriptions([{
|
|
6175
6013
|
subscriptionKey: {
|
|
@@ -6178,13 +6016,13 @@ class ObservabilitySubscriptionManager {
|
|
|
6178
6016
|
key: kafkaTopic
|
|
6179
6017
|
},
|
|
6180
6018
|
cb: (payload) => {
|
|
6181
|
-
|
|
6019
|
+
this.#kafkaHelper.ProcessKafkaData(payload);
|
|
6182
6020
|
}
|
|
6183
6021
|
}]);
|
|
6184
6022
|
}
|
|
6185
6023
|
}
|
|
6186
6024
|
} else {
|
|
6187
|
-
|
|
6025
|
+
this.#LogDebugMessage(chalk.red(`CreateModelServiceInstances():Error: GetModelForService() returned null`));
|
|
6188
6026
|
}
|
|
6189
6027
|
} else {
|
|
6190
6028
|
if (subscribeToKafka) {
|
|
@@ -6202,17 +6040,17 @@ class ObservabilitySubscriptionManager {
|
|
|
6202
6040
|
// serviceId/serviceInstanceId/serviceInstanceProcessId
|
|
6203
6041
|
CreateModelServiceInstance(subscriptionPayload, subscribeToKafka) {
|
|
6204
6042
|
try {
|
|
6205
|
-
|
|
6043
|
+
this.#serviceModel = {};
|
|
6206
6044
|
for (const [serviceId, service] of Object.entries(subscriptionPayload.data)) {
|
|
6207
6045
|
for (const [serviceInstanceId, serviceInstance] of Object.entries(service)) {
|
|
6208
6046
|
for (const [serviceInstanceProcessId, serviceInstanceProcessTelemetry] of Object.entries(serviceInstance)) {
|
|
6209
6047
|
const kafkaTopic = `${KAFKA_PREFIX}_${serviceInstanceId}_${serviceInstanceProcessId}`.replace(/@/g, "_").replace(/\|/g, "_");
|
|
6210
6048
|
if (serviceInstanceProcessTelemetry.cpu && serviceInstanceProcessTelemetry.cpu > 0) {
|
|
6211
|
-
|
|
6212
|
-
if (
|
|
6213
|
-
|
|
6049
|
+
this.#serviceModel[serviceInstanceProcessId] = ObservabilityModelUtils.GetModelForService(serviceInstanceProcessId, serviceInstanceProcessTelemetry, subscribeToKafka, this.#options.logger);
|
|
6050
|
+
if (this.#serviceModel[serviceInstanceProcessId] !== null) {
|
|
6051
|
+
this.#serviceModel[serviceInstanceProcessId].options = { serviceId, serviceInstanceId };
|
|
6214
6052
|
if (subscribeToKafka) {
|
|
6215
|
-
|
|
6053
|
+
this.#kafkaHelper.GetKafkaLogData(kafkaTopic, this.#serviceModel[serviceInstanceProcessId]);
|
|
6216
6054
|
if (!this.FindSubscriptionByKey(kafkaTopic)) {
|
|
6217
6055
|
this.AddSubscriptions([{
|
|
6218
6056
|
subscriptionKey: {
|
|
@@ -6221,13 +6059,13 @@ class ObservabilitySubscriptionManager {
|
|
|
6221
6059
|
key: kafkaTopic
|
|
6222
6060
|
},
|
|
6223
6061
|
cb: (payload) => {
|
|
6224
|
-
|
|
6062
|
+
this.#kafkaHelper.ProcessKafkaData(payload);
|
|
6225
6063
|
}
|
|
6226
6064
|
}]);
|
|
6227
6065
|
}
|
|
6228
6066
|
}
|
|
6229
6067
|
} else {
|
|
6230
|
-
|
|
6068
|
+
this.#LogDebugMessage(chalk.red(`CreateModelServiceInstance():Error: GetModelForService() returned null`));
|
|
6231
6069
|
}
|
|
6232
6070
|
} else {
|
|
6233
6071
|
if (subscribeToKafka) {
|
|
@@ -6247,31 +6085,31 @@ class ObservabilitySubscriptionManager {
|
|
|
6247
6085
|
// /
|
|
6248
6086
|
CreateModelAllAgentsCombined(subscriptionPayload, subscribeToKafka) {
|
|
6249
6087
|
try {
|
|
6250
|
-
|
|
6088
|
+
this.#agentModel = {};
|
|
6251
6089
|
if (subscriptionPayload.subscriptionKey.topic.localeCompare(SubscriptionTopic.AllAgentsCombined.toString()) === 0) {
|
|
6252
6090
|
if (Object.keys(subscriptionPayload.data).length !== 0) {
|
|
6253
|
-
|
|
6254
|
-
if (
|
|
6255
|
-
|
|
6091
|
+
this.#agentModel["STS-Agent"] = ObservabilityModelUtils.GetModelForAgent("STS-Agent", subscriptionPayload.data, subscribeToKafka, this.#options.logger);
|
|
6092
|
+
if (this.#agentModel["STS-Agent"] === null) {
|
|
6093
|
+
this.#LogDebugMessage(chalk.red(`CreateModelAllAgentsCombined():Error: GetModelForAgent() returned null`));
|
|
6256
6094
|
}
|
|
6257
6095
|
}
|
|
6258
6096
|
}
|
|
6259
6097
|
} catch (error) {
|
|
6260
|
-
|
|
6098
|
+
this.#LogErrorMessage(error);
|
|
6261
6099
|
return;
|
|
6262
6100
|
}
|
|
6263
6101
|
}
|
|
6264
6102
|
// /agentId
|
|
6265
6103
|
CreateModelAgents(subscriptionPayload, subscribeToKafka) {
|
|
6266
6104
|
try {
|
|
6267
|
-
|
|
6105
|
+
this.#agentModel = {};
|
|
6268
6106
|
for (const [agentId, agentInstanceTelemetry] of Object.entries(subscriptionPayload.data)) {
|
|
6269
6107
|
const kafkaTopic = `${KAFKA_PREFIX}_${agentId}`.replace(/@/g, "_").replace(/\|/g, "_");
|
|
6270
6108
|
if (agentInstanceTelemetry.timer) {
|
|
6271
|
-
|
|
6272
|
-
if (
|
|
6109
|
+
this.#agentModel[agentId] = ObservabilityModelUtils.GetModelForAgent(agentId, agentInstanceTelemetry, subscribeToKafka, this.#options.logger);
|
|
6110
|
+
if (this.#agentModel[agentId] !== null) {
|
|
6273
6111
|
if (subscribeToKafka) {
|
|
6274
|
-
|
|
6112
|
+
this.#kafkaHelper.GetKafkaLogData(kafkaTopic, this.#agentModel[agentId]);
|
|
6275
6113
|
if (!this.FindSubscriptionByKey(kafkaTopic)) {
|
|
6276
6114
|
this.AddSubscriptions([{
|
|
6277
6115
|
subscriptionKey: {
|
|
@@ -6280,13 +6118,13 @@ class ObservabilitySubscriptionManager {
|
|
|
6280
6118
|
key: kafkaTopic
|
|
6281
6119
|
},
|
|
6282
6120
|
cb: (payload) => {
|
|
6283
|
-
|
|
6121
|
+
this.#kafkaHelper.ProcessKafkaData(payload);
|
|
6284
6122
|
}
|
|
6285
6123
|
}]);
|
|
6286
6124
|
}
|
|
6287
6125
|
}
|
|
6288
6126
|
} else {
|
|
6289
|
-
|
|
6127
|
+
this.#LogDebugMessage(chalk.red(`CreateModelAgents():Error: GetModelForAgent() returned null`));
|
|
6290
6128
|
}
|
|
6291
6129
|
} else {
|
|
6292
6130
|
if (subscribeToKafka) {
|
|
@@ -6297,25 +6135,25 @@ class ObservabilitySubscriptionManager {
|
|
|
6297
6135
|
}
|
|
6298
6136
|
}
|
|
6299
6137
|
} catch (error) {
|
|
6300
|
-
|
|
6138
|
+
this.#LogErrorMessage(chalk.red(`UIControllerAgent:CreateModel(): Error: [${error}]`));
|
|
6301
6139
|
}
|
|
6302
6140
|
}
|
|
6303
6141
|
// /agentId/agentWorkerId
|
|
6304
6142
|
CreateModelAgentWorkers(subscriptionPayload, subscribeToKafka) {
|
|
6305
6143
|
try {
|
|
6306
|
-
|
|
6144
|
+
this.#agentModel = {};
|
|
6307
6145
|
for (const [agentId, agentWorker] of Object.entries(subscriptionPayload.data)) {
|
|
6308
6146
|
for (const [agentWorkerId, agentInstanceTelemetry] of Object.entries(agentWorker)) {
|
|
6309
6147
|
const kafkaTopic = `${KAFKA_PREFIX}_${agentId}_${agentWorkerId}`.replace(/@/g, "_").replace(/\|/g, "_");
|
|
6310
6148
|
if (agentInstanceTelemetry.timer) {
|
|
6311
6149
|
const threadKey = `${agentWorkerId}`;
|
|
6312
|
-
|
|
6313
|
-
if (
|
|
6314
|
-
const coreCount =
|
|
6315
|
-
|
|
6316
|
-
|
|
6150
|
+
this.#agentModel[threadKey] = ObservabilityModelUtils.GetModelForAgent(threadKey, agentInstanceTelemetry, subscribeToKafka, this.#options.logger);
|
|
6151
|
+
if (this.#agentModel[threadKey] !== null) {
|
|
6152
|
+
const coreCount = this.#agentModel[threadKey].instruments[Gauge.CORE_COUNT_GAUGE].val;
|
|
6153
|
+
this.#agentModel[threadKey].canNavigate = coreCount > 0;
|
|
6154
|
+
this.#agentModel[threadKey].options = { agentId };
|
|
6317
6155
|
if (subscribeToKafka) {
|
|
6318
|
-
|
|
6156
|
+
this.#kafkaHelper.GetKafkaLogData(kafkaTopic, this.#agentModel[threadKey]);
|
|
6319
6157
|
if (!this.FindSubscriptionByKey(kafkaTopic)) {
|
|
6320
6158
|
this.AddSubscriptions([{
|
|
6321
6159
|
subscriptionKey: {
|
|
@@ -6324,13 +6162,13 @@ class ObservabilitySubscriptionManager {
|
|
|
6324
6162
|
key: kafkaTopic
|
|
6325
6163
|
},
|
|
6326
6164
|
cb: (payload) => {
|
|
6327
|
-
|
|
6165
|
+
this.#kafkaHelper.ProcessKafkaData(payload);
|
|
6328
6166
|
}
|
|
6329
6167
|
}]);
|
|
6330
6168
|
}
|
|
6331
6169
|
}
|
|
6332
6170
|
} else {
|
|
6333
|
-
|
|
6171
|
+
this.#LogDebugMessage(chalk.red(`CreateModelAgentWorkers():Error: GetModelForAgent() returned null`));
|
|
6334
6172
|
}
|
|
6335
6173
|
} else {
|
|
6336
6174
|
if (subscribeToKafka) {
|
|
@@ -6342,22 +6180,22 @@ class ObservabilitySubscriptionManager {
|
|
|
6342
6180
|
}
|
|
6343
6181
|
}
|
|
6344
6182
|
} catch (error) {
|
|
6345
|
-
|
|
6183
|
+
this.#LogErrorMessage(chalk.red(`UIControllerAgentThreads:CreateModel(): Error: [${error}]`));
|
|
6346
6184
|
}
|
|
6347
6185
|
}
|
|
6348
6186
|
// /agentId/agentWorkerId/asyncRunnerId
|
|
6349
6187
|
CreateModelAgentWorker(subscriptionPayload, subscribeToKafka) {
|
|
6350
6188
|
try {
|
|
6351
|
-
|
|
6189
|
+
this.#agentModel = {};
|
|
6352
6190
|
for (const [agentId, agentWorker] of Object.entries(subscriptionPayload.data)) {
|
|
6353
6191
|
for (const [agentWorkerId, asyncRunnerData] of Object.entries(agentWorker)) {
|
|
6354
6192
|
for (const [asyncRunnerId, agentInstanceTelemetry] of Object.entries(asyncRunnerData)) {
|
|
6355
6193
|
const kafkaTopic = `${KAFKA_PREFIX}_${agentId}_${agentWorkerId}_${asyncRunnerId}`.replace(/@/g, "_").replace(/\|/g, "_");
|
|
6356
6194
|
if (agentInstanceTelemetry.timer) {
|
|
6357
|
-
|
|
6358
|
-
if (
|
|
6195
|
+
this.#agentModel[asyncRunnerId] = ObservabilityModelUtils.GetModelForAgent(asyncRunnerId, agentInstanceTelemetry, subscribeToKafka, this.#options.logger);
|
|
6196
|
+
if (this.#agentModel[asyncRunnerId] !== null) {
|
|
6359
6197
|
if (subscribeToKafka) {
|
|
6360
|
-
|
|
6198
|
+
this.#kafkaHelper.GetKafkaLogData(kafkaTopic, this.#agentModel[asyncRunnerId]);
|
|
6361
6199
|
if (!this.FindSubscriptionByKey(kafkaTopic)) {
|
|
6362
6200
|
this.AddSubscriptions([{
|
|
6363
6201
|
subscriptionKey: {
|
|
@@ -6366,13 +6204,13 @@ class ObservabilitySubscriptionManager {
|
|
|
6366
6204
|
key: kafkaTopic
|
|
6367
6205
|
},
|
|
6368
6206
|
cb: (payload) => {
|
|
6369
|
-
|
|
6207
|
+
this.#kafkaHelper.ProcessKafkaData(payload);
|
|
6370
6208
|
}
|
|
6371
6209
|
}]);
|
|
6372
6210
|
}
|
|
6373
6211
|
}
|
|
6374
6212
|
} else {
|
|
6375
|
-
|
|
6213
|
+
this.#LogDebugMessage(chalk.red(`CreateModelAgentWorker():Error: GetModelForAgent() returned null`));
|
|
6376
6214
|
}
|
|
6377
6215
|
} else {
|
|
6378
6216
|
if (subscribeToKafka) {
|
|
@@ -6385,33 +6223,33 @@ class ObservabilitySubscriptionManager {
|
|
|
6385
6223
|
}
|
|
6386
6224
|
}
|
|
6387
6225
|
} catch (error) {
|
|
6388
|
-
|
|
6226
|
+
this.#LogErrorMessage(chalk.red(`UIControllerAgentThread:CreateModel(): Error: [${error}]`));
|
|
6389
6227
|
}
|
|
6390
6228
|
}
|
|
6391
6229
|
// --- [ Lambdas ] ------------------------------------------------------------------------------------------------------------------------------------------------
|
|
6392
6230
|
// /
|
|
6393
6231
|
CreateModelAllLambdasCombined(subscriptionPayload, subscribeToKafka) {
|
|
6394
6232
|
try {
|
|
6395
|
-
|
|
6233
|
+
this.#lambdaModel = {};
|
|
6396
6234
|
if (subscriptionPayload.subscriptionKey.topic.localeCompare(SubscriptionTopic.AllLambdasCombined.toString()) === 0) {
|
|
6397
|
-
|
|
6398
|
-
if (
|
|
6399
|
-
|
|
6235
|
+
this.#lambdaModel["STS-Lambda"] = ObservabilityModelUtils.GetModelForLambda("STS-Lambda", subscriptionPayload.data, subscribeToKafka, this.#options.logger);
|
|
6236
|
+
if (this.#lambdaModel["STS-Lambda"] === null) {
|
|
6237
|
+
this.#LogDebugMessage(chalk.red(`CreateModelAllLambdasCombined():Error: GetModelForLambda() returned null`));
|
|
6400
6238
|
}
|
|
6401
6239
|
}
|
|
6402
6240
|
} catch (error) {
|
|
6403
|
-
|
|
6241
|
+
this.#LogErrorMessage(error);
|
|
6404
6242
|
return;
|
|
6405
6243
|
}
|
|
6406
6244
|
}
|
|
6407
6245
|
// /technologyId
|
|
6408
6246
|
CreateModelLambdaTechnologies(subscriptionPayload, subscribeToKafka) {
|
|
6409
6247
|
try {
|
|
6410
|
-
|
|
6248
|
+
this.#lambdaModel = {};
|
|
6411
6249
|
for (const [technologyId, technologyTelemetry] of Object.entries(subscriptionPayload.data)) {
|
|
6412
|
-
|
|
6413
|
-
if (
|
|
6414
|
-
|
|
6250
|
+
this.#lambdaModel[technologyId] = ObservabilityModelUtils.GetModelForLambda(technologyId, technologyTelemetry, subscribeToKafka, this.#options.logger);
|
|
6251
|
+
if (this.#lambdaModel[technologyId] === null) {
|
|
6252
|
+
this.#LogDebugMessage(chalk.red(`CreateModelLambdaTechnologies():Error: GetModelForLambda() returned null`));
|
|
6415
6253
|
}
|
|
6416
6254
|
}
|
|
6417
6255
|
} catch (error) {
|
|
@@ -6421,16 +6259,16 @@ class ObservabilitySubscriptionManager {
|
|
|
6421
6259
|
// /technologyId/subTechnologyId
|
|
6422
6260
|
CreateModelLambdaSubTechnologies(subscriptionPayload, subscribeToKafka) {
|
|
6423
6261
|
try {
|
|
6424
|
-
|
|
6262
|
+
this.#lambdaModel = {};
|
|
6425
6263
|
for (const [technologyId, technologyTelemetry] of Object.entries(subscriptionPayload.data)) {
|
|
6426
6264
|
for (const [subTechnologyId, subTechnologyTelemetry] of Object.entries(technologyTelemetry)) {
|
|
6427
6265
|
const kafkaTopic = `${KAFKA_PREFIX}_${subTechnologyId}`.replace(/@/g, "_").replace(/\|/g, "_");
|
|
6428
6266
|
if (subTechnologyTelemetry.cpu && subTechnologyTelemetry.cpu > 0) {
|
|
6429
|
-
|
|
6430
|
-
if (
|
|
6431
|
-
|
|
6267
|
+
this.#lambdaModel[subTechnologyId] = ObservabilityModelUtils.GetModelForLambda(subTechnologyId, subTechnologyTelemetry, subscribeToKafka, this.#options.logger);
|
|
6268
|
+
if (this.#lambdaModel[subTechnologyId] !== null) {
|
|
6269
|
+
this.#lambdaModel[subTechnologyId].options = { technologyId };
|
|
6432
6270
|
if (subscribeToKafka) {
|
|
6433
|
-
|
|
6271
|
+
this.#kafkaHelper.GetKafkaLogData(kafkaTopic, this.#lambdaModel[subTechnologyId]);
|
|
6434
6272
|
if (!this.FindSubscriptionByKey(kafkaTopic)) {
|
|
6435
6273
|
this.AddSubscriptions([{
|
|
6436
6274
|
subscriptionKey: {
|
|
@@ -6439,13 +6277,13 @@ class ObservabilitySubscriptionManager {
|
|
|
6439
6277
|
key: kafkaTopic
|
|
6440
6278
|
},
|
|
6441
6279
|
cb: (payload) => {
|
|
6442
|
-
|
|
6280
|
+
this.#kafkaHelper.ProcessKafkaData(payload);
|
|
6443
6281
|
}
|
|
6444
6282
|
}]);
|
|
6445
6283
|
}
|
|
6446
6284
|
}
|
|
6447
6285
|
} else {
|
|
6448
|
-
|
|
6286
|
+
this.#LogDebugMessage(chalk.red(`CreateModelLambdaSubTechnologies():Error: GetModelForLambda() returned null`));
|
|
6449
6287
|
}
|
|
6450
6288
|
} else {
|
|
6451
6289
|
if (subscribeToKafka) {
|
|
@@ -6463,17 +6301,17 @@ class ObservabilitySubscriptionManager {
|
|
|
6463
6301
|
// /technologyId/subTechnologyId/subTechnologyInstanceId
|
|
6464
6302
|
CreateModelLambdaSubTechnologiesInstance(subscriptionPayload, subscribeToKafka) {
|
|
6465
6303
|
try {
|
|
6466
|
-
|
|
6304
|
+
this.#lambdaModel = {};
|
|
6467
6305
|
for (const [technologyId, technologyTelemetry] of Object.entries(subscriptionPayload.data)) {
|
|
6468
6306
|
for (const [subTechnologyId, subTechnologyTelemetry] of Object.entries(technologyTelemetry)) {
|
|
6469
6307
|
for (const [subTechnologyInstanceId, subTechnologyInstanceTelemetry] of Object.entries(subTechnologyTelemetry)) {
|
|
6470
6308
|
const kafkaTopic = `${KAFKA_PREFIX}_${subTechnologyId}_${subTechnologyInstanceId}`.replace(/@/g, "_").replace(/\|/g, "_");
|
|
6471
6309
|
if (subTechnologyInstanceTelemetry.cpu && subTechnologyInstanceTelemetry.cpu > 0) {
|
|
6472
|
-
|
|
6473
|
-
if (
|
|
6474
|
-
|
|
6310
|
+
this.#lambdaModel[subTechnologyInstanceId] = ObservabilityModelUtils.GetModelForLambda(subTechnologyInstanceId, subTechnologyInstanceTelemetry, subscribeToKafka, this.#options.logger);
|
|
6311
|
+
if (this.#lambdaModel[subTechnologyInstanceId] !== null) {
|
|
6312
|
+
this.#lambdaModel[subTechnologyInstanceId].options = { technologyId, subTechnologyId };
|
|
6475
6313
|
if (subscribeToKafka) {
|
|
6476
|
-
|
|
6314
|
+
this.#kafkaHelper.GetKafkaLogData(kafkaTopic, this.#lambdaModel[subTechnologyInstanceId]);
|
|
6477
6315
|
if (!this.FindSubscriptionByKey(kafkaTopic)) {
|
|
6478
6316
|
this.AddSubscriptions([{
|
|
6479
6317
|
subscriptionKey: {
|
|
@@ -6482,13 +6320,13 @@ class ObservabilitySubscriptionManager {
|
|
|
6482
6320
|
key: kafkaTopic
|
|
6483
6321
|
},
|
|
6484
6322
|
cb: (payload) => {
|
|
6485
|
-
|
|
6323
|
+
this.#kafkaHelper.ProcessKafkaData(payload);
|
|
6486
6324
|
}
|
|
6487
6325
|
}]);
|
|
6488
6326
|
}
|
|
6489
6327
|
}
|
|
6490
6328
|
} else {
|
|
6491
|
-
|
|
6329
|
+
this.#LogDebugMessage(chalk.red(`CreateModelLambdaSubTechnologiesInstance():Error: GetModelForLambda() returned null`));
|
|
6492
6330
|
}
|
|
6493
6331
|
} else {
|
|
6494
6332
|
if (subscribeToKafka) {
|
|
@@ -6505,20 +6343,6 @@ class ObservabilitySubscriptionManager {
|
|
|
6505
6343
|
}
|
|
6506
6344
|
}
|
|
6507
6345
|
}
|
|
6508
|
-
_observabilitySocketIOSubscriber = new WeakMap();
|
|
6509
|
-
_subscriptions = new WeakMap();
|
|
6510
|
-
_kafkaHelper = new WeakMap();
|
|
6511
|
-
_serviceModel = new WeakMap();
|
|
6512
|
-
_agentModel = new WeakMap();
|
|
6513
|
-
_lambdaModel = new WeakMap();
|
|
6514
|
-
_options5 = new WeakMap();
|
|
6515
|
-
_ObservabilitySubscriptionManager_instances = new WeakSet();
|
|
6516
|
-
LogDebugMessage_fn4 = function(message) {
|
|
6517
|
-
__privateGet(this, _options5).logger.debug(message);
|
|
6518
|
-
};
|
|
6519
|
-
LogErrorMessage_fn3 = function(message) {
|
|
6520
|
-
__privateGet(this, _options5).logger.error(message);
|
|
6521
|
-
};
|
|
6522
6346
|
export {
|
|
6523
6347
|
CompareSTSInstrumentControllerPluginKey,
|
|
6524
6348
|
CreateInstrument,
|