@nsshunt/stsobservability 1.0.69 → 1.0.71

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.
@@ -21,7 +21,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
21
21
  }
22
22
  });
23
23
 
24
- 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, _httpsAgent, _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, _options6, _sockets, _httpsAgent2, _SocketIoClientHelper_instances, LogDebugMessage_fn5, LogErrorMessage_fn4, EstablishSocketConnect_fn;
24
+ 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, _httpsAgent, _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, _options6, _sockets, _httpsAgent2, _SocketIoClientHelper_instances, LogDebugMessage_fn5, LogErrorMessage_fn4, EstablishSocketConnect_fn, _socketIoServerHelperOptions, _namespace, _SetupStandardEvents, _SetupConnectionMiddleware, _SetupMessageMiddleware;
25
25
  var Gauge = /* @__PURE__ */ ((Gauge2) => {
26
26
  Gauge2["ACTIVE_REQUEST_GAUGE"] = "a";
27
27
  Gauge2["AUTHENTICATION_COUNT_GAUGE"] = "b";
@@ -6626,6 +6626,149 @@ var __privateWrapper = (obj, member, setter, getter) => ({
6626
6626
  }
6627
6627
  });
6628
6628
  };
6629
+ var STSNamespace = /* @__PURE__ */ ((STSNamespace2) => {
6630
+ STSNamespace2["STSMonitor"] = "stsinstrumentmanager/stsmonitor";
6631
+ STSNamespace2["STSControl"] = "stsinstrumentmanager/stscontrol";
6632
+ return STSNamespace2;
6633
+ })(STSNamespace || {});
6634
+ var STSRoom = /* @__PURE__ */ ((STSRoom2) => {
6635
+ STSRoom2["STSInstrumentDataRoom"] = "stsinstrumentdataroom";
6636
+ STSRoom2["STSInstrumentDataSubscriptionRoom"] = "stsinstrumentdatasubscriptionroom";
6637
+ STSRoom2["STSRunnerRoom"] = "stsrunnerroom";
6638
+ STSRoom2["STSNodeRunnerRoom"] = "stsnoderunnerroom";
6639
+ return STSRoom2;
6640
+ })(STSRoom || {});
6641
+ var STSEvent = /* @__PURE__ */ ((STSEvent2) => {
6642
+ STSEvent2["STSInstrumentData"] = "stsinstrumentdata";
6643
+ STSEvent2["STSSubInstrumentData"] = "stssubinstrumentdata";
6644
+ STSEvent2["STSResetInstrumentData"] = "stsresetinstrumentdata";
6645
+ STSEvent2["STSStartLoggingInstrumentData"] = "stsStartLoggingInstrumentData";
6646
+ STSEvent2["STSStopLoggingInstrumentData"] = "stsStopLoggingInstrumentData";
6647
+ STSEvent2["STSStart"] = "stsstart";
6648
+ STSEvent2["STSStop"] = "stsstop";
6649
+ STSEvent2["STSPause"] = "stspause";
6650
+ STSEvent2["STSResume"] = "stsresume";
6651
+ STSEvent2["STSTerminate"] = "ststerminate";
6652
+ STSEvent2["STSUpdateStaticConfig"] = "stsupdatestaticconfig";
6653
+ STSEvent2["STSUpdateDynamicConfig"] = "stsupdatedynamicconfig";
6654
+ STSEvent2["STSSendToRoom"] = "sendToRoom";
6655
+ STSEvent2["connect"] = "connect";
6656
+ return STSEvent2;
6657
+ })(STSEvent || {});
6658
+ class SocketIoServerHelper {
6659
+ constructor(options) {
6660
+ __privateAdd(this, _socketIoServerHelperOptions);
6661
+ __privateAdd(this, _namespace, {});
6662
+ __publicField(this, "LeaveRoom", (namespace, socket, room) => {
6663
+ this.LogMessage(namespace, `${namespace.socketionamespace.name}: Leaving room [${room}]`);
6664
+ socket.leave(room);
6665
+ });
6666
+ __publicField(this, "JoinRoom", (namespace, socket, room) => {
6667
+ this.LogMessage(namespace, `${namespace.socketionamespace.name}: Socket joining room [${room}], ID: [${socket.id}]`);
6668
+ socket.join(room);
6669
+ });
6670
+ __privateAdd(this, _SetupStandardEvents, (namespace, socket) => {
6671
+ socket.on("disconnect", (reason) => {
6672
+ this.LogMessage(namespace, `${namespace.socketionamespace.name}: socket disconnect, ID: [${socket.id}] [${reason}]`);
6673
+ });
6674
+ socket.on("disconnecting", (reason) => {
6675
+ this.LogMessage(namespace, `${namespace.socketionamespace.name}: socket disconnecting, ID: [${socket.id}] [${reason}]`);
6676
+ });
6677
+ socket.on("error", (error) => {
6678
+ this.LogMessage(namespace, `${namespace.socketionamespace.name}: socket error, ID: [${socket.id}] [${error}]`);
6679
+ });
6680
+ socket.on("__STSdisconnect", (reason) => {
6681
+ this.LogMessage(namespace, `${namespace.socketionamespace.name}: __STSdisconnect: socket disconnect, ID: [${socket.id}] [${reason}]`);
6682
+ });
6683
+ socket.on("__STSdisconnecting", (reason, callBackResult) => {
6684
+ this.LogMessage(namespace, `${namespace.socketionamespace.name}: __STSdisconnecting: socket disconnecting, ID: [${socket.id}] [${reason}]`);
6685
+ callBackResult("__STSdisconnecting accepted by server.");
6686
+ });
6687
+ socket.on("__STSjoinRoom", (rooms) => {
6688
+ rooms.forEach((room) => {
6689
+ this.JoinRoom(namespace, socket, room);
6690
+ });
6691
+ });
6692
+ socket.on("__STSleaveRoom", (rooms) => {
6693
+ rooms.forEach((room) => {
6694
+ this.LeaveRoom(namespace, socket, room);
6695
+ });
6696
+ });
6697
+ socket.on("__STSsendToRoom", (rooms, payload) => {
6698
+ rooms.forEach((room) => {
6699
+ this.LogMessage(namespace, `${namespace.socketionamespace.name}:socket.on:sendToRoom: __STSsendToRoom: Sending to room [${room}], ID: [${socket.id}]`);
6700
+ namespace.socketionamespace.to(room).emit(payload.command, payload);
6701
+ });
6702
+ });
6703
+ });
6704
+ // Use this middleward to check every incomming connection
6705
+ __privateAdd(this, _SetupConnectionMiddleware, (nameSpace) => {
6706
+ nameSpace.socketionamespace.use((socket, next) => {
6707
+ {
6708
+ next();
6709
+ }
6710
+ });
6711
+ });
6712
+ // Use this middleware to check very packet being received
6713
+ __privateAdd(this, _SetupMessageMiddleware, (socket) => {
6714
+ socket.use(([event, ...args], next) => {
6715
+ next();
6716
+ });
6717
+ });
6718
+ __publicField(this, "SetupNamespace", (io, namespace, rooms, autoJoinRooms, socketConnectCallBack, socketEventsCallBack) => {
6719
+ __privateGet(this, _namespace)[namespace] = {
6720
+ namespace,
6721
+ pid: process.pid,
6722
+ socketionamespace: io.of(`/${namespace}/`)
6723
+ };
6724
+ __privateGet(this, _SetupConnectionMiddleware).call(this, __privateGet(this, _namespace)[namespace]);
6725
+ __privateGet(this, _namespace)[namespace].socketionamespace.on("connection", (socket) => {
6726
+ this.LogMessage(__privateGet(this, _namespace)[namespace], `${namespace}: Socket connected, ID: [${socket.id}]`);
6727
+ this.LogMessage(__privateGet(this, _namespace)[namespace], `${namespace}: Authentication Handshake: [${JSON.stringify(socket.handshake.auth)}]`);
6728
+ __privateGet(this, _SetupMessageMiddleware).call(this, socket);
6729
+ if (autoJoinRooms) {
6730
+ rooms.map((room) => {
6731
+ this.JoinRoom(__privateGet(this, _namespace)[namespace], socket, room);
6732
+ });
6733
+ }
6734
+ __privateGet(this, _SetupStandardEvents).call(this, __privateGet(this, _namespace)[namespace], socket);
6735
+ if (socketConnectCallBack) {
6736
+ setTimeout(() => {
6737
+ socketConnectCallBack(socket);
6738
+ }, 0);
6739
+ }
6740
+ if (socketEventsCallBack) {
6741
+ socketEventsCallBack(socket);
6742
+ }
6743
+ });
6744
+ return __privateGet(this, _namespace)[namespace].socketionamespace;
6745
+ });
6746
+ __publicField(this, "GetSTSSocketIONamespace", (namespace) => {
6747
+ return __privateGet(this, _namespace)[namespace];
6748
+ });
6749
+ __publicField(this, "GetSTSSocketIONamespaces", () => {
6750
+ return __privateGet(this, _namespace);
6751
+ });
6752
+ __publicField(this, "DisconnectSockets", () => {
6753
+ for (const [, namespace] of Object.entries(__privateGet(this, _namespace))) {
6754
+ namespace.socketionamespace.disconnectSockets();
6755
+ }
6756
+ __privateSet(this, _namespace, {});
6757
+ });
6758
+ __privateSet(this, _socketIoServerHelperOptions, options);
6759
+ }
6760
+ LogMessage(namespace, message) {
6761
+ __privateGet(this, _socketIoServerHelperOptions).logger.debug(`${namespace.namespace}: ${message}`);
6762
+ }
6763
+ SetupEvent(event, eventCb) {
6764
+ return this;
6765
+ }
6766
+ }
6767
+ _socketIoServerHelperOptions = new WeakMap();
6768
+ _namespace = new WeakMap();
6769
+ _SetupStandardEvents = new WeakMap();
6770
+ _SetupConnectionMiddleware = new WeakMap();
6771
+ _SetupMessageMiddleware = new WeakMap();
6629
6772
  exports2.CompareSTSInstrumentControllerPluginKey = CompareSTSInstrumentControllerPluginKey;
6630
6773
  exports2.CreateInstrument = CreateInstrument;
6631
6774
  exports2.Gauge = Gauge;
@@ -6669,10 +6812,14 @@ var __privateWrapper = (obj, member, setter, getter) => ({
6669
6812
  exports2.PublishTransportRESTServer = PublishTransportRESTServer;
6670
6813
  exports2.RequestLoggerMiddleware = RequestLoggerMiddleware;
6671
6814
  exports2.RequestLoggerMiddlewareEventName = RequestLoggerMiddlewareEventName;
6815
+ exports2.STSEvent = STSEvent;
6672
6816
  exports2.STSInstrumentControllerPlugin = STSInstrumentControllerPlugin;
6673
6817
  exports2.STSInstrumentControllerPluginKey = STSInstrumentControllerPluginKey;
6818
+ exports2.STSNamespace = STSNamespace;
6819
+ exports2.STSRoom = STSRoom;
6674
6820
  exports2.SocketIoClientHelper = SocketIoClientHelper;
6675
6821
  exports2.SocketIoMessageSender = SocketIoMessageSender;
6822
+ exports2.SocketIoServerHelper = SocketIoServerHelper;
6676
6823
  exports2.StopInstruments = StopInstruments;
6677
6824
  exports2.SubscriptionTopic = SubscriptionTopic;
6678
6825
  exports2.TransportType = TransportType;