@nsshunt/stsobservability 1.0.74 → 1.0.76

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.
@@ -17,7 +17,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
17
17
  return __privateGet(obj, member, getter);
18
18
  }
19
19
  });
20
- var _a, _label, _options2, _data2, _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, _agentManager2, _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, _options3, _ObservabilityRESTAPISubscriber_instances, LogDebugMessage_fn, LogErrorMessage_fn, InvokeRESTAPI_fn, _GetData, SetupTimeout_fn, AddKeepAlive_fn, RemoveKeepAlive_fn, _messageWithAckPayloadRecords, _socket, _maxReties, _timeoutValue, _options4, _SocketIoMessageSender_instances, LogDebugMessage_fn2, GetSubscribeKeepAliveAckEventName_fn, _socketSubscribeKeepAlive2, _socket2, _options5, _socketIoMessageSender, _ObservabilitySocketIOSubscriber_instances, LogDebugMessage_fn3, LogErrorMessage_fn2, AddKeepAlive_fn2, RemoveKeepAlive_fn2, _observabilitySocketIOSubscriber, _subscriptions, _kafkaHelper, _serviceModel, _agentModel, _lambdaModel, _options6, _ObservabilitySubscriptionManager_instances, LogDebugMessage_fn4, LogErrorMessage_fn3, _options7, _sockets, _httpsAgent2, _SocketIoClientHelper_instances, LogDebugMessage_fn5, LogErrorMessage_fn4, EstablishSocketConnect_fn, _socketIoServerHelperOptions, _namespace, _SetupStandardEvents, _SetupConnectionMiddleware, _SetupMessageMiddleware;
20
+ var _a, _label, _options2, _data2, _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, _agentManager2, _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, _options3, _agentManager3, _ObservabilityRESTAPISubscriber_instances, LogDebugMessage_fn, LogErrorMessage_fn, InvokeRESTAPI_fn, _GetData, SetupTimeout_fn, AddKeepAlive_fn, RemoveKeepAlive_fn, _messageWithAckPayloadRecords, _socket, _maxReties, _timeoutValue, _options4, _SocketIoMessageSender_instances, LogDebugMessage_fn2, GetSubscribeKeepAliveAckEventName_fn, _socketSubscribeKeepAlive2, _socket2, _options5, _socketIoMessageSender, _ObservabilitySocketIOSubscriber_instances, LogDebugMessage_fn3, LogErrorMessage_fn2, AddKeepAlive_fn2, RemoveKeepAlive_fn2, _observabilitySocketIOSubscriber, _subscriptions, _kafkaHelper, _serviceModel, _agentModel, _lambdaModel, _options6, _ObservabilitySubscriptionManager_instances, LogDebugMessage_fn4, LogErrorMessage_fn3, _options7, _sockets, _agentManager4, _SocketIoClientHelper_instances, LogDebugMessage_fn5, LogErrorMessage_fn4, EstablishSocketConnect_fn, _socketIoServerHelperOptions, _namespace, _SetupStandardEvents, _SetupConnectionMiddleware, _SetupMessageMiddleware;
21
21
  import _cloneDeep from "lodash.clonedeep";
22
22
  import isNode from "detect-node";
23
23
  import { STSOptionsBase } from "@nsshunt/stsutils";
@@ -6564,10 +6564,12 @@ class AgentManager {
6564
6564
  __privateAdd2(this, _agentResetInterval, null);
6565
6565
  __privateAdd2(this, _requestCount, 0);
6566
6566
  __privateAdd2(this, _SetupResetInterval, () => {
6567
- __privateSet2(this, _agentResetInterval, setTimeout(() => {
6568
- this.ResetAgent();
6569
- __privateGet2(this, _SetupResetInterval).call(this);
6570
- }, __privateGet2(this, _options).agentResetInterval).unref());
6567
+ if (__privateGet2(this, _options).agentResetInterval && __privateGet2(this, _options).agentResetInterval > 0) {
6568
+ __privateSet2(this, _agentResetInterval, setTimeout(() => {
6569
+ this.ResetAgent();
6570
+ __privateGet2(this, _SetupResetInterval).call(this);
6571
+ }, __privateGet2(this, _options).agentResetInterval).unref());
6572
+ }
6571
6573
  });
6572
6574
  __privateAdd2(this, _GetAgentOptions, (https2) => {
6573
6575
  let options;
@@ -6603,6 +6605,22 @@ class AgentManager {
6603
6605
  __privateGet2(this, _SetupResetInterval).call(this);
6604
6606
  }
6605
6607
  }
6608
+ get agentResetInterval() {
6609
+ return __privateGet2(this, _options).agentResetInterval;
6610
+ }
6611
+ set agentResetInterval(val) {
6612
+ if (__privateGet2(this, _agentResetInterval)) {
6613
+ clearTimeout(__privateGet2(this, _agentResetInterval));
6614
+ }
6615
+ __privateGet2(this, _options).agentResetInterval = val;
6616
+ __privateGet2(this, _SetupResetInterval).call(this);
6617
+ }
6618
+ get agentResetCount() {
6619
+ return __privateGet2(this, _options).agentResetCount;
6620
+ }
6621
+ set agentResetCount(val) {
6622
+ __privateGet2(this, _options).agentResetCount = val;
6623
+ }
6606
6624
  IncRequestCount() {
6607
6625
  __privateWrapper2(this, _requestCount)._++;
6608
6626
  if (__privateGet2(this, _options).agentResetCount) {
@@ -6751,7 +6769,6 @@ class PublishTransportRESTServer extends STSOptionsBase {
6751
6769
  //data: payload,
6752
6770
  data: Buffer.from(encodedData),
6753
6771
  headers,
6754
- //httpsAgent: this.#httpsAgent,
6755
6772
  socketPath: this.options.socketPath
6756
6773
  });
6757
6774
  } else {
@@ -7666,6 +7683,7 @@ class ObservabilityRESTAPISubscriber {
7666
7683
  __privateAdd(this, _options3);
7667
7684
  // 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.
7668
7685
  __publicField(this, "KeepAliveAckBoundFunction");
7686
+ __privateAdd(this, _agentManager3, null);
7669
7687
  __privateAdd(this, _GetData, async (subscription) => {
7670
7688
  try {
7671
7689
  const retVal = await __privateMethod(this, _ObservabilityRESTAPISubscriber_instances, InvokeRESTAPI_fn).call(this, subscription);
@@ -7682,6 +7700,9 @@ class ObservabilityRESTAPISubscriber {
7682
7700
  }
7683
7701
  });
7684
7702
  __privateSet(this, _options3, options);
7703
+ if (isNode && options.useAgentManager && options.useAgentManager === true) {
7704
+ __privateSet(this, _agentManager3, new AgentManager({}));
7705
+ }
7685
7706
  }
7686
7707
  SubscribeOne(subscription) {
7687
7708
  this.Subscribe([subscription]);
@@ -7710,6 +7731,7 @@ class ObservabilityRESTAPISubscriber {
7710
7731
  }
7711
7732
  _socketSubscribeKeepAlive = new WeakMap();
7712
7733
  _options3 = new WeakMap();
7734
+ _agentManager3 = new WeakMap();
7713
7735
  _ObservabilityRESTAPISubscriber_instances = new WeakSet();
7714
7736
  LogDebugMessage_fn = function(message) {
7715
7737
  __privateGet(this, _options3).logger.debug(message);
@@ -7792,13 +7814,8 @@ InvokeRESTAPI_fn = async function(subscription) {
7792
7814
  let retVal;
7793
7815
  const start = performance.now();
7794
7816
  try {
7795
- if (isNode && __privateGet(this, _options3).agent) {
7796
- retVal = await axios({
7797
- url: endPointUrl,
7798
- method: "get",
7799
- headers,
7800
- httpsAgent: __privateGet(this, _options3).agent
7801
- });
7817
+ if (isNode && __privateGet(this, _agentManager3)) {
7818
+ retVal = await axios(new STSAxiosConfig(endPointUrl, "get", headers).withAgentManager(__privateGet(this, _agentManager3)).config);
7802
7819
  } else {
7803
7820
  retVal = await axios({
7804
7821
  url: endPointUrl,
@@ -8670,18 +8687,11 @@ class SocketIoClientHelper {
8670
8687
  __privateAdd(this, _SocketIoClientHelper_instances);
8671
8688
  __privateAdd(this, _options7);
8672
8689
  __privateAdd(this, _sockets, {});
8673
- __privateAdd(this, _httpsAgent2, null);
8690
+ __privateAdd(this, _agentManager4, null);
8674
8691
  __privateSet(this, _options7, options);
8675
8692
  if (isNode) {
8676
- const agentOptions = __privateGet(this, _options7).agentOptions;
8677
- __privateSet(this, _httpsAgent2, new https.Agent({
8678
- keepAlive: agentOptions == null ? void 0 : agentOptions.keepAlive,
8679
- maxSockets: agentOptions == null ? void 0 : agentOptions.maxSockets,
8680
- maxTotalSockets: agentOptions == null ? void 0 : agentOptions.maxTotalSockets,
8681
- maxFreeSockets: agentOptions == null ? void 0 : agentOptions.maxFreeSockets,
8682
- timeout: agentOptions == null ? void 0 : agentOptions.timeout,
8683
- rejectUnauthorized: agentOptions == null ? void 0 : agentOptions.rejectUnauthorized
8684
- // Allows self signed certs in non production mode(s)
8693
+ __privateSet(this, _agentManager4, new AgentManager({
8694
+ agentOptions: __privateGet(this, _options7).agentOptions
8685
8695
  }));
8686
8696
  }
8687
8697
  }
@@ -8707,7 +8717,7 @@ class SocketIoClientHelper {
8707
8717
  }
8708
8718
  _options7 = new WeakMap();
8709
8719
  _sockets = new WeakMap();
8710
- _httpsAgent2 = new WeakMap();
8720
+ _agentManager4 = new WeakMap();
8711
8721
  _SocketIoClientHelper_instances = new WeakSet();
8712
8722
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
8713
8723
  LogDebugMessage_fn5 = function(message) {
@@ -8718,6 +8728,7 @@ LogErrorMessage_fn4 = function(message) {
8718
8728
  if (__privateGet(this, _options7).logger) __privateGet(this, _options7).logger.error(message);
8719
8729
  };
8720
8730
  EstablishSocketConnect_fn = function(name2, onConnectCallBack, socketEventsCallBack) {
8731
+ var _a2;
8721
8732
  const socketDetail = this.sockets[name2];
8722
8733
  if (socketDetail.socket !== null) {
8723
8734
  if (socketDetail.socket.connected === true) {
@@ -8736,8 +8747,7 @@ EstablishSocketConnect_fn = function(name2, onConnectCallBack, socketEventsCallB
8736
8747
  socketOptions = {
8737
8748
  transports: ["websocket"],
8738
8749
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
8739
- agent: __privateGet(this, _httpsAgent2)
8740
- // Custom https agent
8750
+ agent: (_a2 = __privateGet(this, _agentManager4)) == null ? void 0 : _a2.GetAgent(socketDetail.address)
8741
8751
  };
8742
8752
  } else {
8743
8753
  socketOptions = {