@nsshunt/stsobservability 0.0.4 → 0.0.5
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 +147 -1
- package/dist/stsobservability.mjs.map +1 -1
- package/dist/stsobservability.umd.js +148 -3
- package/dist/stsobservability.umd.js.map +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +1 -3
- package/types/index.d.ts.map +1 -1
- package/types/instrumentation/instrumentUtils.d.ts +1 -2
- package/types/instrumentation/instrumentUtils.d.ts.map +1 -1
- package/types/instrumentation/instruments/instrumentBase.d.ts +2 -1
- package/types/instrumentation/instruments/instrumentBase.d.ts.map +1 -1
- package/types/instrumentation/index.d.ts +0 -13
- package/types/instrumentation/index.d.ts.map +0 -1
|
@@ -34,7 +34,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
34
34
|
__accessCheck(obj, member, "access private method");
|
|
35
35
|
return method;
|
|
36
36
|
};
|
|
37
|
-
var _label, _options, _data, _a, _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, _ComputeVelocityByTimeDiff, ComputeVelocityByTimeDiff_fn, _ComputeVelocity, ComputeVelocity_fn, _SetupAutoComputeVelocity, SetupAutoComputeVelocity_fn, _GetVelocityStackAverage, GetVelocityStackAverage_fn, _GetVal, GetVal_fn, _SetVal, SetVal_fn, _GetVelocity, GetVelocity_fn, _GetMaxVelocity, GetMaxVelocity_fn, _GetDelta, GetDelta_fn, _GetTimeStamp, GetTimeStamp_fn, _GetCountDiff, GetCountDiff_fn, _GetTimeDiff, GetTimeDiff_fn, _GetDeltaCountDiff, GetDeltaCountDiff_fn, _GetDeltaTimeDif, GetDeltaTimeDif_fn, _GetAverageVelocity, GetAverageVelocity_fn, _histogramData, _val, _copy2, _GetVal2, GetVal_fn2, _SetVal2, SetVal_fn2, _GetHistogramData, GetHistogramData_fn, _SetHistogramData, SetHistogramData_fn, _messages, _readPos, _maxSize, _copy3, _useLatestMessages, _consoleLogging, _instrumentLogging, _winstonLogging, _stsLogger, _DumpToConsole, DumpToConsole_fn, _GetVal3, GetVal_fn3, _SetVal3, SetVal_fn3, _start, _copy4, _pauseVal, _GetVal4, GetVal_fn4, _SetVal4, SetVal_fn4, _convertMS, convertMS_fn, _val2, _maxval, _lastObservedValue, _timeSeriesList, _maxSampleSize, _timerInterval2, _observer, _min, _max, _observations, _total, _copy5, _GetVal5, GetVal_fn5, _SetVal5, SetVal_fn5, _GetMin, GetMin_fn, _GetMax, GetMax_fn, _GetAverage, GetAverage_fn, _GetAndResetMaxVal, GetAndResetMaxVal_fn, _NumberCompare, NumberCompare_fn, _GetPercentileData, GetPercentileData_fn, _val3, _copy6, _GetVal6, GetVal_fn6, _SetVal6, SetVal_fn6, _tinyEmitter, _RequestCompleted, _instruments, _inPublish, _observer2, _publishState, _GetInstrument, GetInstrument_fn, _ProcessTelemetryCommand, ProcessTelemetryCommand_fn, _CreateInstrument, CreateInstrument_fn, _CreateInstruments, CreateInstruments_fn, _GetPayloadData, GetPayloadData_fn, _PublishTimeoutLoop, PublishTimeoutLoop_fn, _httpsAgent, _kafkaLog, _maxLogLength, _socketSubscribeKeepAlive, _options2, _LogMessage, LogMessage_fn, _LogDebugMessage, LogDebugMessage_fn, _LogErrorMessage, LogErrorMessage_fn, _InvokeRESTAPI, InvokeRESTAPI_fn, _GetData, _SetupTimeout, SetupTimeout_fn, _AddKeepAlive, AddKeepAlive_fn, _RemoveKeepAlive, RemoveKeepAlive_fn, _messageWithAckPayloadRecords, _socket, _maxReties, _timeoutValue, _options3, _LogDebugMessage2, LogDebugMessage_fn2, _GetSubscribeKeepAliveAckEventName, GetSubscribeKeepAliveAckEventName_fn, _socketSubscribeKeepAlive2, _socket2, _options4, _socketIoMessageSender, _LogDebugMessage3, LogDebugMessage_fn3, _LogErrorMessage2, LogErrorMessage_fn2, _AddKeepAlive2, AddKeepAlive_fn2, _RemoveKeepAlive2, RemoveKeepAlive_fn2, _observabilitySocketIOSubscriber, _subscriptions, _kafkaHelper, _serviceModel, _agentModel, _lambdaModel, _options5, _LogDebugMessage4, LogDebugMessage_fn4, _LogErrorMessage3, LogErrorMessage_fn3;
|
|
37
|
+
var _label, _options, _data, _a, _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, _ComputeVelocityByTimeDiff, ComputeVelocityByTimeDiff_fn, _ComputeVelocity, ComputeVelocity_fn, _SetupAutoComputeVelocity, SetupAutoComputeVelocity_fn, _GetVelocityStackAverage, GetVelocityStackAverage_fn, _GetVal, GetVal_fn, _SetVal, SetVal_fn, _GetVelocity, GetVelocity_fn, _GetMaxVelocity, GetMaxVelocity_fn, _GetDelta, GetDelta_fn, _GetTimeStamp, GetTimeStamp_fn, _GetCountDiff, GetCountDiff_fn, _GetTimeDiff, GetTimeDiff_fn, _GetDeltaCountDiff, GetDeltaCountDiff_fn, _GetDeltaTimeDif, GetDeltaTimeDif_fn, _GetAverageVelocity, GetAverageVelocity_fn, _histogramData, _val, _copy2, _GetVal2, GetVal_fn2, _SetVal2, SetVal_fn2, _GetHistogramData, GetHistogramData_fn, _SetHistogramData, SetHistogramData_fn, _messages, _readPos, _maxSize, _copy3, _useLatestMessages, _consoleLogging, _instrumentLogging, _winstonLogging, _stsLogger, _DumpToConsole, DumpToConsole_fn, _GetVal3, GetVal_fn3, _SetVal3, SetVal_fn3, _start, _copy4, _pauseVal, _GetVal4, GetVal_fn4, _SetVal4, SetVal_fn4, _convertMS, convertMS_fn, _val2, _maxval, _lastObservedValue, _timeSeriesList, _maxSampleSize, _timerInterval2, _observer, _min, _max, _observations, _total, _copy5, _GetVal5, GetVal_fn5, _SetVal5, SetVal_fn5, _GetMin, GetMin_fn, _GetMax, GetMax_fn, _GetAverage, GetAverage_fn, _GetAndResetMaxVal, GetAndResetMaxVal_fn, _NumberCompare, NumberCompare_fn, _GetPercentileData, GetPercentileData_fn, _val3, _copy6, _GetVal6, GetVal_fn6, _SetVal6, SetVal_fn6, _tinyEmitter, _RequestCompleted, _instruments, _inPublish, _observer2, _publishState, _GetInstrument, GetInstrument_fn, _ProcessTelemetryCommand, ProcessTelemetryCommand_fn, _CreateInstrument, CreateInstrument_fn, _CreateInstruments, CreateInstruments_fn, _GetPayloadData, GetPayloadData_fn, _PublishTimeoutLoop, PublishTimeoutLoop_fn, _httpsAgent, _kafkaLog, _maxLogLength, _socketSubscribeKeepAlive, _options2, _LogMessage, LogMessage_fn, _LogDebugMessage, LogDebugMessage_fn, _LogErrorMessage, LogErrorMessage_fn, _InvokeRESTAPI, InvokeRESTAPI_fn, _GetData, _SetupTimeout, SetupTimeout_fn, _AddKeepAlive, AddKeepAlive_fn, _RemoveKeepAlive, RemoveKeepAlive_fn, _messageWithAckPayloadRecords, _socket, _maxReties, _timeoutValue, _options3, _LogDebugMessage2, LogDebugMessage_fn2, _GetSubscribeKeepAliveAckEventName, GetSubscribeKeepAliveAckEventName_fn, _socketSubscribeKeepAlive2, _socket2, _options4, _socketIoMessageSender, _LogDebugMessage3, LogDebugMessage_fn3, _LogErrorMessage2, LogErrorMessage_fn2, _AddKeepAlive2, AddKeepAlive_fn2, _RemoveKeepAlive2, RemoveKeepAlive_fn2, _observabilitySocketIOSubscriber, _subscriptions, _kafkaHelper, _serviceModel, _agentModel, _lambdaModel, _options5, _LogDebugMessage4, LogDebugMessage_fn4, _LogErrorMessage3, LogErrorMessage_fn3, _options6, _sockets, _httpsAgent2, _LogDebugMessage5, LogDebugMessage_fn5, _LogErrorMessage4, LogErrorMessage_fn4, _EstablishSocketConnect, EstablishSocketConnect_fn;
|
|
38
38
|
import _cloneDeep from "lodash.clonedeep";
|
|
39
39
|
import isNode from "detect-node";
|
|
40
40
|
import { STSOptionsBase } from "@nsshunt/stsutils";
|
|
@@ -44,6 +44,7 @@ import { inject } from "vue";
|
|
|
44
44
|
import https from "node:https";
|
|
45
45
|
import axios from "axios";
|
|
46
46
|
import debugModule from "debug";
|
|
47
|
+
import { io } from "socket.io-client";
|
|
47
48
|
var Gauge = /* @__PURE__ */ ((Gauge2) => {
|
|
48
49
|
Gauge2["ACTIVE_REQUEST_GAUGE"] = "a";
|
|
49
50
|
Gauge2["AUTHENTICATION_COUNT_GAUGE"] = "b";
|
|
@@ -6384,6 +6385,150 @@ _LogErrorMessage3 = new WeakSet();
|
|
|
6384
6385
|
LogErrorMessage_fn3 = function(message) {
|
|
6385
6386
|
__privateGet(this, _options5).logger.error(message);
|
|
6386
6387
|
};
|
|
6388
|
+
class SocketIoClientHelper {
|
|
6389
|
+
constructor(options) {
|
|
6390
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6391
|
+
__privateAdd(this, _LogDebugMessage5);
|
|
6392
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6393
|
+
__privateAdd(this, _LogErrorMessage4);
|
|
6394
|
+
__privateAdd(this, _EstablishSocketConnect);
|
|
6395
|
+
__privateAdd(this, _options6, void 0);
|
|
6396
|
+
__privateAdd(this, _sockets, {});
|
|
6397
|
+
__privateAdd(this, _httpsAgent2, null);
|
|
6398
|
+
__privateSet(this, _options6, options);
|
|
6399
|
+
if (isNode) {
|
|
6400
|
+
const agentOptions = __privateGet(this, _options6).agentOptions;
|
|
6401
|
+
__privateSet(this, _httpsAgent2, new https.Agent({
|
|
6402
|
+
keepAlive: agentOptions == null ? void 0 : agentOptions.keepAlive,
|
|
6403
|
+
maxSockets: agentOptions == null ? void 0 : agentOptions.maxSockets,
|
|
6404
|
+
maxTotalSockets: agentOptions == null ? void 0 : agentOptions.maxTotalSockets,
|
|
6405
|
+
maxFreeSockets: agentOptions == null ? void 0 : agentOptions.maxFreeSockets,
|
|
6406
|
+
timeout: agentOptions == null ? void 0 : agentOptions.timeout,
|
|
6407
|
+
rejectUnauthorized: agentOptions == null ? void 0 : agentOptions.rejectUnauthorized
|
|
6408
|
+
// Allows self signed certs in non production mode(s)
|
|
6409
|
+
}));
|
|
6410
|
+
}
|
|
6411
|
+
}
|
|
6412
|
+
get sockets() {
|
|
6413
|
+
return __privateGet(this, _sockets);
|
|
6414
|
+
}
|
|
6415
|
+
SetupClientSideSocket(name, address, onConnectCallBack, socketEventsCallBack, errorCallBack) {
|
|
6416
|
+
this.sockets[name] = {
|
|
6417
|
+
name,
|
|
6418
|
+
address,
|
|
6419
|
+
socket: null,
|
|
6420
|
+
errorCallBack
|
|
6421
|
+
};
|
|
6422
|
+
__privateMethod(this, _EstablishSocketConnect, EstablishSocketConnect_fn).call(this, name, onConnectCallBack, socketEventsCallBack);
|
|
6423
|
+
return this.sockets[name].socket;
|
|
6424
|
+
}
|
|
6425
|
+
GetSocket(name) {
|
|
6426
|
+
return this.sockets[name].socket;
|
|
6427
|
+
}
|
|
6428
|
+
GetSocketDetail(name) {
|
|
6429
|
+
return this.sockets[name];
|
|
6430
|
+
}
|
|
6431
|
+
}
|
|
6432
|
+
_options6 = new WeakMap();
|
|
6433
|
+
_sockets = new WeakMap();
|
|
6434
|
+
_httpsAgent2 = new WeakMap();
|
|
6435
|
+
_LogDebugMessage5 = new WeakSet();
|
|
6436
|
+
LogDebugMessage_fn5 = function(message) {
|
|
6437
|
+
if (__privateGet(this, _options6).logger)
|
|
6438
|
+
__privateGet(this, _options6).logger.debug(message);
|
|
6439
|
+
};
|
|
6440
|
+
_LogErrorMessage4 = new WeakSet();
|
|
6441
|
+
LogErrorMessage_fn4 = function(message) {
|
|
6442
|
+
if (__privateGet(this, _options6).logger)
|
|
6443
|
+
__privateGet(this, _options6).logger.error(message);
|
|
6444
|
+
};
|
|
6445
|
+
_EstablishSocketConnect = new WeakSet();
|
|
6446
|
+
EstablishSocketConnect_fn = function(name, onConnectCallBack, socketEventsCallBack) {
|
|
6447
|
+
const socketDetail = this.sockets[name];
|
|
6448
|
+
if (socketDetail.socket !== null) {
|
|
6449
|
+
if (socketDetail.socket.connected === true) {
|
|
6450
|
+
socketDetail.socket.disconnect();
|
|
6451
|
+
}
|
|
6452
|
+
socketDetail.socket = null;
|
|
6453
|
+
if (isNode) {
|
|
6454
|
+
setTimeout(() => __privateMethod(this, _EstablishSocketConnect, EstablishSocketConnect_fn).call(this, name, onConnectCallBack, socketEventsCallBack), 100).unref();
|
|
6455
|
+
} else {
|
|
6456
|
+
setTimeout(() => __privateMethod(this, _EstablishSocketConnect, EstablishSocketConnect_fn).call(this, name, onConnectCallBack, socketEventsCallBack), 100);
|
|
6457
|
+
}
|
|
6458
|
+
return;
|
|
6459
|
+
}
|
|
6460
|
+
let socketOptions;
|
|
6461
|
+
if (isNode) {
|
|
6462
|
+
socketOptions = {
|
|
6463
|
+
transports: ["websocket"],
|
|
6464
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6465
|
+
agent: __privateGet(this, _httpsAgent2)
|
|
6466
|
+
// Custom https agent
|
|
6467
|
+
};
|
|
6468
|
+
} else {
|
|
6469
|
+
socketOptions = {
|
|
6470
|
+
transports: ["websocket"]
|
|
6471
|
+
};
|
|
6472
|
+
}
|
|
6473
|
+
socketDetail.socket = io(socketDetail.address, socketOptions);
|
|
6474
|
+
socketDetail.socket.on("connect", () => {
|
|
6475
|
+
if (socketDetail.socket) {
|
|
6476
|
+
__privateMethod(this, _LogDebugMessage5, LogDebugMessage_fn5).call(this, `Socket: [${socketDetail.socket.id}]: connected`);
|
|
6477
|
+
if (onConnectCallBack) {
|
|
6478
|
+
setTimeout(() => {
|
|
6479
|
+
onConnectCallBack(socketDetail.socket);
|
|
6480
|
+
}, 0);
|
|
6481
|
+
}
|
|
6482
|
+
if (socketEventsCallBack) {
|
|
6483
|
+
socketEventsCallBack(socketDetail.socket);
|
|
6484
|
+
}
|
|
6485
|
+
} else {
|
|
6486
|
+
const errorMessage = "Could not get socket object from socket.io";
|
|
6487
|
+
__privateMethod(this, _LogErrorMessage4, LogErrorMessage_fn4).call(this, errorMessage);
|
|
6488
|
+
socketDetail.errorCallBack(new Error(errorMessage));
|
|
6489
|
+
}
|
|
6490
|
+
});
|
|
6491
|
+
socketDetail.socket.on("disconnect", (reason) => {
|
|
6492
|
+
__privateMethod(this, _LogDebugMessage5, LogDebugMessage_fn5).call(this, "socket disconnect: " + reason);
|
|
6493
|
+
switch (reason) {
|
|
6494
|
+
case "io server disconnect":
|
|
6495
|
+
{
|
|
6496
|
+
__privateMethod(this, _LogDebugMessage5, LogDebugMessage_fn5).call(this, "The server disconnected using disconnectSockets, i.e. normal safe shutdown from explicit disconnection by the server.");
|
|
6497
|
+
__privateMethod(this, _LogDebugMessage5, LogDebugMessage_fn5).call(this, "The connection will be re-established when the server becomes available.");
|
|
6498
|
+
const socketDetail2 = this.sockets[name];
|
|
6499
|
+
socketDetail2.socket = null;
|
|
6500
|
+
if (isNode) {
|
|
6501
|
+
setTimeout(() => __privateMethod(this, _EstablishSocketConnect, EstablishSocketConnect_fn).call(this, name, onConnectCallBack, socketEventsCallBack), 100).unref();
|
|
6502
|
+
} else {
|
|
6503
|
+
setTimeout(() => __privateMethod(this, _EstablishSocketConnect, EstablishSocketConnect_fn).call(this, name, onConnectCallBack, socketEventsCallBack), 100);
|
|
6504
|
+
}
|
|
6505
|
+
}
|
|
6506
|
+
break;
|
|
6507
|
+
case "io client disconnect":
|
|
6508
|
+
__privateMethod(this, _LogDebugMessage5, LogDebugMessage_fn5).call(this, "The client disconnected using disconnectSockets, i.e. normal safe disconnection from explicit disconnection by the client.");
|
|
6509
|
+
__privateMethod(this, _LogDebugMessage5, LogDebugMessage_fn5).call(this, "The connection will not be re-established automatically.");
|
|
6510
|
+
break;
|
|
6511
|
+
case "transport close":
|
|
6512
|
+
case "ping timeout":
|
|
6513
|
+
case "transport error":
|
|
6514
|
+
{
|
|
6515
|
+
__privateMethod(this, _LogDebugMessage5, LogDebugMessage_fn5).call(this, `Server unexpectedly disconnected. Reason: [${reason}]`);
|
|
6516
|
+
__privateMethod(this, _LogDebugMessage5, LogDebugMessage_fn5).call(this, "The connection will be re-established when the server becomes available.");
|
|
6517
|
+
const socketDetail2 = this.sockets[name];
|
|
6518
|
+
if (socketDetail2.socket) {
|
|
6519
|
+
socketDetail2.socket.disconnect();
|
|
6520
|
+
}
|
|
6521
|
+
socketDetail2.socket = null;
|
|
6522
|
+
if (isNode) {
|
|
6523
|
+
setTimeout(() => __privateMethod(this, _EstablishSocketConnect, EstablishSocketConnect_fn).call(this, name, onConnectCallBack, socketEventsCallBack), 100).unref();
|
|
6524
|
+
} else {
|
|
6525
|
+
setTimeout(() => __privateMethod(this, _EstablishSocketConnect, EstablishSocketConnect_fn).call(this, name, onConnectCallBack, socketEventsCallBack), 100);
|
|
6526
|
+
}
|
|
6527
|
+
}
|
|
6528
|
+
break;
|
|
6529
|
+
}
|
|
6530
|
+
});
|
|
6531
|
+
};
|
|
6387
6532
|
export {
|
|
6388
6533
|
AgentInstrumentController,
|
|
6389
6534
|
CompareSTSInstrumentControllerPluginKey,
|
|
@@ -6430,6 +6575,7 @@ export {
|
|
|
6430
6575
|
RequestLoggerMiddlewareEventName,
|
|
6431
6576
|
STSInstrumentControllerPlugin,
|
|
6432
6577
|
STSInstrumentControllerPluginKey,
|
|
6578
|
+
SocketIoClientHelper,
|
|
6433
6579
|
StopInstruments,
|
|
6434
6580
|
SubscriptionTopic,
|
|
6435
6581
|
TransportType,
|