@nsshunt/stsobservability 1.0.131 → 1.0.132

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.
@@ -5299,7 +5299,7 @@ class ObservabilityModelUtils {
5299
5299
  }
5300
5300
  });
5301
5301
  }
5302
- static GetModelForService(id, data, subscribeToKafka, logger) {
5302
+ static GetModelForService(id, data, logger) {
5303
5303
  try {
5304
5304
  const parseLog = [];
5305
5305
  const model = {
@@ -5307,9 +5307,7 @@ class ObservabilityModelUtils {
5307
5307
  instruments: {}
5308
5308
  };
5309
5309
  this.GetModelData("service", model, data, parseLog);
5310
- if (!subscribeToKafka) {
5311
- model.instruments[Gauge.LOGGER] = ObservabilityModelUtils.GetModelNodeRawStringArray(data["logMessages"]);
5312
- }
5310
+ model.instruments[Gauge.LOGGER] = ObservabilityModelUtils.GetModelNodeRawStringArray(data["logMessages"]);
5313
5311
  if (parseLog.length > 0) {
5314
5312
  parseLog.forEach((logEntry) => logger.debug(logEntry));
5315
5313
  }
@@ -5318,7 +5316,7 @@ class ObservabilityModelUtils {
5318
5316
  return null;
5319
5317
  }
5320
5318
  }
5321
- static GetModelForLambda(id, data, subscribeToKafka, logger) {
5319
+ static GetModelForLambda(id, data, logger) {
5322
5320
  try {
5323
5321
  const parseLog = [];
5324
5322
  const model = {
@@ -5326,9 +5324,7 @@ class ObservabilityModelUtils {
5326
5324
  instruments: {}
5327
5325
  };
5328
5326
  this.GetModelData("lambda", model, data, parseLog);
5329
- if (!subscribeToKafka) {
5330
- model.instruments[Gauge.LOGGER] = ObservabilityModelUtils.GetModelNodeRawStringArray(data["logMessages"]);
5331
- }
5327
+ model.instruments[Gauge.LOGGER] = ObservabilityModelUtils.GetModelNodeRawStringArray(data["logMessages"]);
5332
5328
  if (parseLog.length > 0) {
5333
5329
  parseLog.forEach((logEntry) => logger.debug(logEntry));
5334
5330
  }
@@ -5337,7 +5333,7 @@ class ObservabilityModelUtils {
5337
5333
  return null;
5338
5334
  }
5339
5335
  }
5340
- static GetModelForAgent(id, data, subscribeToKafka, logger) {
5336
+ static GetModelForAgent(id, data, logger) {
5341
5337
  try {
5342
5338
  if (Object.keys(data).length === 0) {
5343
5339
  return null;
@@ -5348,9 +5344,7 @@ class ObservabilityModelUtils {
5348
5344
  instruments: {}
5349
5345
  };
5350
5346
  this.GetModelData("agent", model, data, parseLog);
5351
- if (!subscribeToKafka) {
5352
- model.instruments[Gauge.LOGGER] = ObservabilityModelUtils.GetModelNodeRawStringArray(data["logMessages"]);
5353
- }
5347
+ model.instruments[Gauge.LOGGER] = ObservabilityModelUtils.GetModelNodeRawStringArray(data["logMessages"]);
5354
5348
  if (parseLog.length > 0) {
5355
5349
  parseLog.forEach((logEntry) => logger.debug(logEntry));
5356
5350
  }
@@ -5360,36 +5354,6 @@ class ObservabilityModelUtils {
5360
5354
  }
5361
5355
  }
5362
5356
  }
5363
- class KafkaHelper {
5364
- #kafkaLog = {};
5365
- #maxLogLength;
5366
- constructor(options) {
5367
- this.#maxLogLength = options.maxLogLength;
5368
- }
5369
- GetKafkaLogData = (kafkaTopic, modelNode) => {
5370
- if (this.#kafkaLog[kafkaTopic]) {
5371
- modelNode.instruments[Gauge.LOGGER] = ObservabilityModelUtils.GetModelNodeRawStringArray(this.#kafkaLog[kafkaTopic].kafkaLog);
5372
- }
5373
- };
5374
- ProcessKafkaData = (payload) => {
5375
- const { data } = payload;
5376
- if (data) {
5377
- const kafkaData = data;
5378
- const { kafkaTopic, value } = kafkaData;
5379
- if (!this.#kafkaLog[kafkaTopic]) {
5380
- this.#kafkaLog[kafkaTopic] = {
5381
- kafkaTopic: `${kafkaTopic}`,
5382
- //@@ why is this needed
5383
- kafkaLog: []
5384
- };
5385
- }
5386
- this.#kafkaLog[kafkaTopic].kafkaLog.push(value);
5387
- while (this.#kafkaLog[kafkaTopic].kafkaLog.length > this.#maxLogLength) {
5388
- this.#kafkaLog[kafkaTopic].kafkaLog.shift();
5389
- }
5390
- }
5391
- };
5392
- }
5393
5357
  class ObservabilityRESTAPISubscriber {
5394
5358
  #socketSubscribeKeepAlive = {};
5395
5359
  #options;
@@ -5646,42 +5610,6 @@ class ObservabilitySocketIOSubscriber {
5646
5610
  });
5647
5611
  }
5648
5612
  }
5649
- const byteToHex = [];
5650
- for (let i = 0; i < 256; ++i) {
5651
- byteToHex.push((i + 256).toString(16).slice(1));
5652
- }
5653
- function unsafeStringify(arr, offset = 0) {
5654
- return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
5655
- }
5656
- let getRandomValues;
5657
- const rnds8 = new Uint8Array(16);
5658
- function rng() {
5659
- if (!getRandomValues) {
5660
- if (typeof crypto === "undefined" || !crypto.getRandomValues) {
5661
- throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
5662
- }
5663
- getRandomValues = crypto.getRandomValues.bind(crypto);
5664
- }
5665
- return getRandomValues(rnds8);
5666
- }
5667
- const randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
5668
- const native = { randomUUID };
5669
- function _v4(options, buf, offset) {
5670
- options = options || {};
5671
- const rnds = options.random ?? options.rng?.() ?? rng();
5672
- if (rnds.length < 16) {
5673
- throw new Error("Random bytes length must be >= 16");
5674
- }
5675
- rnds[6] = rnds[6] & 15 | 64;
5676
- rnds[8] = rnds[8] & 63 | 128;
5677
- return unsafeStringify(rnds);
5678
- }
5679
- function v4(options, buf, offset) {
5680
- if (native.randomUUID && true && !options) {
5681
- return native.randomUUID();
5682
- }
5683
- return _v4(options);
5684
- }
5685
5613
  var runStates = /* @__PURE__ */ ((runStates2) => {
5686
5614
  runStates2["idle"] = "idle";
5687
5615
  runStates2["started"] = "started";
@@ -5689,43 +5617,18 @@ var runStates = /* @__PURE__ */ ((runStates2) => {
5689
5617
  return runStates2;
5690
5618
  })(runStates || {});
5691
5619
  class ObservabilitySubscriptionManager {
5692
- #observabilitySocketIOSubscriber = null;
5693
- #subscriptions = [];
5694
- #kafkaHelper;
5695
5620
  #serviceModel = {};
5696
5621
  #agentModel = {};
5697
5622
  #lambdaModel = {};
5698
5623
  #options;
5699
- #runState = "idle";
5700
5624
  #LogDebugMessage(message) {
5701
5625
  this.#options.logger.debug(message);
5702
5626
  }
5703
5627
  #LogErrorMessage(message) {
5704
5628
  this.#options.logger.error(message);
5705
5629
  }
5706
- #LogWarnMessage(message) {
5707
- this.#options.logger.warn(message);
5708
- }
5709
5630
  constructor(options) {
5710
5631
  this.#options = options;
5711
- this.#kafkaHelper = new KafkaHelper({
5712
- maxLogLength: this.#options.maxLogLength
5713
- });
5714
- }
5715
- get runState() {
5716
- return this.#runState;
5717
- }
5718
- get observabilitySocketIOSubscriber() {
5719
- return this.#observabilitySocketIOSubscriber;
5720
- }
5721
- set observabilitySocketIOSubscriber(observabilitySocketIOSubscriber) {
5722
- this.#observabilitySocketIOSubscriber = observabilitySocketIOSubscriber;
5723
- }
5724
- get subscriptions() {
5725
- return this.#subscriptions;
5726
- }
5727
- set subscriptions(subscriptions) {
5728
- this.#subscriptions = subscriptions;
5729
5632
  }
5730
5633
  get serviceModel() {
5731
5634
  return this.#serviceModel;
@@ -5736,131 +5639,56 @@ class ObservabilitySubscriptionManager {
5736
5639
  get lambdaModel() {
5737
5640
  return this.#lambdaModel;
5738
5641
  }
5739
- AddSubscriptions(subscriptions) {
5740
- const subscriptionsToAdd = [];
5741
- subscriptions.map((subscription) => {
5742
- const retVal = this.subscriptions.find((v) => v.subscriptionKey.id.localeCompare(subscription.subscriptionKey.id) === 0);
5743
- if (retVal) {
5744
- this.#LogDebugMessage(chalk.magenta(`AddSubscription(): Subscription: [${retVal.subscriptionKey.id}] already exists - ignoring.`));
5745
- } else {
5746
- subscriptionsToAdd.push(subscription);
5747
- }
5748
- });
5749
- if (subscriptionsToAdd.length > 0) {
5750
- subscriptionsToAdd.map((s) => this.subscriptions.push(s));
5751
- this.#observabilitySocketIOSubscriber?.Subscribe(subscriptionsToAdd);
5752
- } else {
5753
- this.#LogDebugMessage(chalk.magenta(`AddSubscription(): No valid subscriptions to subscribe.`));
5754
- }
5755
- }
5756
- RemoveSubscriptionsByKey(keyToFind) {
5757
- const newSubscriptions = [];
5758
- for (let i = 0; i < this.subscriptions.length; i++) {
5759
- if (this.subscriptions[i].subscriptionKey.key?.localeCompare(keyToFind) === 0) {
5760
- if (this.#observabilitySocketIOSubscriber) {
5761
- this.#observabilitySocketIOSubscriber.UnSubscribe([this.subscriptions[i]]);
5762
- }
5763
- } else {
5764
- newSubscriptions.push(this.subscriptions[i]);
5765
- }
5766
- }
5767
- this.#subscriptions = newSubscriptions;
5768
- }
5769
- FindSubscriptionByKey(keyToFind) {
5770
- for (let i = 0; i < this.subscriptions.length; i++) {
5771
- if (this.subscriptions[i].subscriptionKey.key?.localeCompare(keyToFind) === 0) {
5772
- return this.subscriptions[i];
5773
- }
5774
- }
5775
- return void 0;
5776
- }
5777
- FindSubscriptionByKeyAndSubKey(keyToFind, subKeyToFind) {
5778
- for (let i = 0; i < this.subscriptions.length; i++) {
5779
- if (this.subscriptions[i].subscriptionKey.key?.localeCompare(keyToFind) === 0) {
5780
- if (this.subscriptions[i].subscriptionKey.subkey?.localeCompare(subKeyToFind) === 0) {
5781
- return this.subscriptions[i];
5782
- }
5783
- }
5784
- }
5785
- return void 0;
5786
- }
5787
- Start() {
5788
- const initialState = this.#runState;
5789
- if (this.#runState === "started") {
5790
- this.#LogWarnMessage(`ObservabilitySubscriptionManager:Start(): Warning: [run state already started]`);
5791
- }
5792
- if (this.#observabilitySocketIOSubscriber) {
5793
- this.#LogDebugMessage(`ObservabilitySubscriptionManager:Start(): observabilitySocketIOSubscriber.Subscribe(${JSON.stringify(this.subscriptions)})`);
5794
- this.#observabilitySocketIOSubscriber.Subscribe(this.subscriptions);
5795
- }
5796
- this.#runState = "started";
5797
- this.#LogDebugMessage(`ObservabilitySubscriptionManager:Start(): runState: [${this.#runState}] (was: [${initialState}])`);
5798
- }
5799
- Stop() {
5800
- const initialState = this.#runState;
5801
- if (this.#runState === "stopped") {
5802
- this.#LogWarnMessage(`ObservabilitySubscriptionManager:Stop(): Warning: [run state already stopped]`);
5803
- }
5804
- if (this.#runState === "idle") {
5805
- this.#LogWarnMessage(`ObservabilitySubscriptionManager:Stop(): Warning: [run state currently idle (not started)]`);
5806
- }
5807
- if (this.#observabilitySocketIOSubscriber) {
5808
- this.#LogDebugMessage(`ObservabilitySubscriptionManager:Start(): observabilitySocketIOSubscriber.UnSubscribe(${JSON.stringify(this.subscriptions)})`);
5809
- this.#observabilitySocketIOSubscriber.UnSubscribe(this.subscriptions);
5810
- }
5811
- this.#runState = "stopped";
5812
- this.#LogDebugMessage(`ObservabilitySubscriptionManager:Start(): runState: [${this.#runState}] (was: [${initialState}])`);
5813
- }
5814
- TransformSubscriptionPayloadCallback(subscriptionPayload, subscribeToKafka) {
5642
+ TransformSubscriptionPayloadCallback(subscriptionPayload) {
5815
5643
  switch (subscriptionPayload.subscriptionKey.topic) {
5816
5644
  // Services -----------------------------------------------------------------------------
5817
5645
  case SubscriptionTopic.AllServicesCombined:
5818
- this.CreateModelAllServicesCombined(subscriptionPayload, subscribeToKafka);
5646
+ this.CreateModelAllServicesCombined(subscriptionPayload);
5819
5647
  break;
5820
5648
  case SubscriptionTopic.Services:
5821
- this.CreateModelServices(subscriptionPayload, subscribeToKafka);
5649
+ this.CreateModelServices(subscriptionPayload);
5822
5650
  break;
5823
5651
  case SubscriptionTopic.ServiceInstances:
5824
- this.CreateModelServiceInstances(subscriptionPayload, subscribeToKafka);
5652
+ this.CreateModelServiceInstances(subscriptionPayload);
5825
5653
  break;
5826
5654
  case SubscriptionTopic.ServiceInstance:
5827
- this.CreateModelServiceInstance(subscriptionPayload, subscribeToKafka);
5655
+ this.CreateModelServiceInstance(subscriptionPayload);
5828
5656
  break;
5829
5657
  // Lambda -----------------------------------------------------------------------------
5830
5658
  case SubscriptionTopic.AllLambdasCombined:
5831
- this.CreateModelAllLambdasCombined(subscriptionPayload, subscribeToKafka);
5659
+ this.CreateModelAllLambdasCombined(subscriptionPayload);
5832
5660
  break;
5833
5661
  case SubscriptionTopic.LambdaTechnologies:
5834
- this.CreateModelLambdaTechnologies(subscriptionPayload, subscribeToKafka);
5662
+ this.CreateModelLambdaTechnologies(subscriptionPayload);
5835
5663
  break;
5836
5664
  case SubscriptionTopic.LambdaSubTechnologies:
5837
- this.CreateModelLambdaSubTechnologies(subscriptionPayload, subscribeToKafka);
5665
+ this.CreateModelLambdaSubTechnologies(subscriptionPayload);
5838
5666
  break;
5839
5667
  case SubscriptionTopic.LambdaSubTechnologiesInstance:
5840
- this.CreateModelLambdaSubTechnologiesInstance(subscriptionPayload, subscribeToKafka);
5668
+ this.CreateModelLambdaSubTechnologiesInstance(subscriptionPayload);
5841
5669
  break;
5842
5670
  // Agents -----------------------------------------------------------------------------
5843
5671
  case SubscriptionTopic.AllAgentsCombined:
5844
- this.CreateModelAllAgentsCombined(subscriptionPayload, subscribeToKafka);
5672
+ this.CreateModelAllAgentsCombined(subscriptionPayload);
5845
5673
  break;
5846
5674
  case SubscriptionTopic.Agents:
5847
- this.CreateModelAgents(subscriptionPayload, subscribeToKafka);
5675
+ this.CreateModelAgents(subscriptionPayload);
5848
5676
  break;
5849
5677
  case SubscriptionTopic.AgentWorkers:
5850
- this.CreateModelAgentWorkers(subscriptionPayload, subscribeToKafka);
5678
+ this.CreateModelAgentWorkers(subscriptionPayload);
5851
5679
  break;
5852
5680
  case SubscriptionTopic.AgentWorker:
5853
- this.CreateModelAgentWorker(subscriptionPayload, subscribeToKafka);
5681
+ this.CreateModelAgentWorker(subscriptionPayload);
5854
5682
  break;
5855
5683
  }
5856
5684
  }
5857
5685
  // --- [ Services ] ------------------------------------------------------------------------------------------------------------------------------------------------
5858
5686
  // /
5859
- CreateModelAllServicesCombined(subscriptionPayload, subscribeToKafka) {
5687
+ CreateModelAllServicesCombined(subscriptionPayload) {
5860
5688
  try {
5861
5689
  this.#serviceModel = {};
5862
5690
  if (subscriptionPayload.subscriptionKey.topic.localeCompare(SubscriptionTopic.AllServicesCombined.toString()) === 0) {
5863
- this.#serviceModel["STS-Service"] = ObservabilityModelUtils.GetModelForService("STS-Service", subscriptionPayload.data, subscribeToKafka, this.#options.logger);
5691
+ this.#serviceModel["STS-Service"] = ObservabilityModelUtils.GetModelForService("STS-Service", subscriptionPayload.data, this.#options.logger);
5864
5692
  if (this.#serviceModel["STS-Service"] === null) {
5865
5693
  this.#LogDebugMessage(chalk.red(`CreateModelAllServicesCombined():Error: GetModelForService() returned null`));
5866
5694
  }
@@ -5871,11 +5699,11 @@ class ObservabilitySubscriptionManager {
5871
5699
  }
5872
5700
  }
5873
5701
  // /serviceId
5874
- CreateModelServices(subscriptionPayload, subscribeToKafka) {
5702
+ CreateModelServices(subscriptionPayload) {
5875
5703
  try {
5876
5704
  this.#serviceModel = {};
5877
5705
  for (const [serviceId, serviceTelemetry] of Object.entries(subscriptionPayload.data)) {
5878
- this.#serviceModel[serviceId] = ObservabilityModelUtils.GetModelForService(serviceId, serviceTelemetry, subscribeToKafka, this.#options.logger);
5706
+ this.#serviceModel[serviceId] = ObservabilityModelUtils.GetModelForService(serviceId, serviceTelemetry, this.#options.logger);
5879
5707
  if (this.#serviceModel[serviceId] === null) {
5880
5708
  this.#LogDebugMessage(chalk.red(`CreateModelServices():Error: GetModelForService() returned null`));
5881
5709
  }
@@ -5885,40 +5713,18 @@ class ObservabilitySubscriptionManager {
5885
5713
  }
5886
5714
  }
5887
5715
  // /serviceId/serviceInstanceId
5888
- CreateModelServiceInstances(subscriptionPayload, subscribeToKafka) {
5716
+ CreateModelServiceInstances(subscriptionPayload) {
5889
5717
  try {
5890
5718
  this.#serviceModel = {};
5891
5719
  for (const [serviceId, service] of Object.entries(subscriptionPayload.data)) {
5892
5720
  for (const [serviceInstanceId, serviceInstanceTelemetry] of Object.entries(service)) {
5893
- const kafkaTopic = `${KAFKA_PREFIX}_${serviceInstanceId}`.replace(/@/g, "_").replace(/\|/g, "_");
5894
5721
  if (serviceInstanceTelemetry.cpu && serviceInstanceTelemetry.cpu > 0) {
5895
- this.#serviceModel[serviceInstanceId] = ObservabilityModelUtils.GetModelForService(serviceInstanceId, serviceInstanceTelemetry, subscribeToKafka, this.#options.logger);
5722
+ this.#serviceModel[serviceInstanceId] = ObservabilityModelUtils.GetModelForService(serviceInstanceId, serviceInstanceTelemetry, this.#options.logger);
5896
5723
  if (this.#serviceModel[serviceInstanceId] !== null) {
5897
5724
  this.#serviceModel[serviceInstanceId].options = { serviceId };
5898
- if (subscribeToKafka) {
5899
- this.#kafkaHelper.GetKafkaLogData(kafkaTopic, this.#serviceModel[serviceInstanceId]);
5900
- if (!this.FindSubscriptionByKey(kafkaTopic)) {
5901
- this.AddSubscriptions([{
5902
- subscriptionKey: {
5903
- id: v4(),
5904
- topic: SubscriptionTopic.LogProcessing,
5905
- key: kafkaTopic
5906
- },
5907
- cb: (payload) => {
5908
- this.#kafkaHelper.ProcessKafkaData(payload);
5909
- }
5910
- }]);
5911
- }
5912
- }
5913
5725
  } else {
5914
5726
  this.#LogDebugMessage(chalk.red(`CreateModelServiceInstances():Error: GetModelForService() returned null`));
5915
5727
  }
5916
- } else {
5917
- if (subscribeToKafka) {
5918
- if (this.FindSubscriptionByKey(kafkaTopic)) {
5919
- this.RemoveSubscriptionsByKey(kafkaTopic);
5920
- }
5921
- }
5922
5728
  }
5923
5729
  }
5924
5730
  }
@@ -5927,41 +5733,19 @@ class ObservabilitySubscriptionManager {
5927
5733
  }
5928
5734
  }
5929
5735
  // serviceId/serviceInstanceId/serviceInstanceProcessId
5930
- CreateModelServiceInstance(subscriptionPayload, subscribeToKafka) {
5736
+ CreateModelServiceInstance(subscriptionPayload) {
5931
5737
  try {
5932
5738
  this.#serviceModel = {};
5933
5739
  for (const [serviceId, service] of Object.entries(subscriptionPayload.data)) {
5934
5740
  for (const [serviceInstanceId, serviceInstance] of Object.entries(service)) {
5935
5741
  for (const [serviceInstanceProcessId, serviceInstanceProcessTelemetry] of Object.entries(serviceInstance)) {
5936
- const kafkaTopic = `${KAFKA_PREFIX}_${serviceInstanceId}_${serviceInstanceProcessId}`.replace(/@/g, "_").replace(/\|/g, "_");
5937
5742
  if (serviceInstanceProcessTelemetry.cpu && serviceInstanceProcessTelemetry.cpu > 0) {
5938
- this.#serviceModel[serviceInstanceProcessId] = ObservabilityModelUtils.GetModelForService(serviceInstanceProcessId, serviceInstanceProcessTelemetry, subscribeToKafka, this.#options.logger);
5743
+ this.#serviceModel[serviceInstanceProcessId] = ObservabilityModelUtils.GetModelForService(serviceInstanceProcessId, serviceInstanceProcessTelemetry, this.#options.logger);
5939
5744
  if (this.#serviceModel[serviceInstanceProcessId] !== null) {
5940
5745
  this.#serviceModel[serviceInstanceProcessId].options = { serviceId, serviceInstanceId };
5941
- if (subscribeToKafka) {
5942
- this.#kafkaHelper.GetKafkaLogData(kafkaTopic, this.#serviceModel[serviceInstanceProcessId]);
5943
- if (!this.FindSubscriptionByKey(kafkaTopic)) {
5944
- this.AddSubscriptions([{
5945
- subscriptionKey: {
5946
- id: v4(),
5947
- topic: SubscriptionTopic.LogProcessing,
5948
- key: kafkaTopic
5949
- },
5950
- cb: (payload) => {
5951
- this.#kafkaHelper.ProcessKafkaData(payload);
5952
- }
5953
- }]);
5954
- }
5955
- }
5956
5746
  } else {
5957
5747
  this.#LogDebugMessage(chalk.red(`CreateModelServiceInstance():Error: GetModelForService() returned null`));
5958
5748
  }
5959
- } else {
5960
- if (subscribeToKafka) {
5961
- if (this.FindSubscriptionByKey(kafkaTopic)) {
5962
- this.RemoveSubscriptionsByKey(kafkaTopic);
5963
- }
5964
- }
5965
5749
  }
5966
5750
  }
5967
5751
  }
@@ -5972,12 +5756,12 @@ class ObservabilitySubscriptionManager {
5972
5756
  }
5973
5757
  // --- [ Agents ] ------------------------------------------------------------------------------------------------------------------------------------------------
5974
5758
  // /
5975
- CreateModelAllAgentsCombined(subscriptionPayload, subscribeToKafka) {
5759
+ CreateModelAllAgentsCombined(subscriptionPayload) {
5976
5760
  try {
5977
5761
  this.#agentModel = {};
5978
5762
  if (subscriptionPayload.subscriptionKey.topic.localeCompare(SubscriptionTopic.AllAgentsCombined.toString()) === 0) {
5979
5763
  if (Object.keys(subscriptionPayload.data).length !== 0) {
5980
- this.#agentModel["STS-Agent"] = ObservabilityModelUtils.GetModelForAgent("STS-Agent", subscriptionPayload.data, subscribeToKafka, this.#options.logger);
5764
+ this.#agentModel["STS-Agent"] = ObservabilityModelUtils.GetModelForAgent("STS-Agent", subscriptionPayload.data, this.#options.logger);
5981
5765
  if (this.#agentModel["STS-Agent"] === null) {
5982
5766
  this.#LogDebugMessage(chalk.red(`CreateModelAllAgentsCombined():Error: GetModelForAgent() returned null`));
5983
5767
  }
@@ -5989,38 +5773,16 @@ class ObservabilitySubscriptionManager {
5989
5773
  }
5990
5774
  }
5991
5775
  // /agentId
5992
- CreateModelAgents(subscriptionPayload, subscribeToKafka) {
5776
+ CreateModelAgents(subscriptionPayload) {
5993
5777
  try {
5994
5778
  this.#agentModel = {};
5995
5779
  for (const [agentId, agentInstanceTelemetry] of Object.entries(subscriptionPayload.data)) {
5996
- const kafkaTopic = `${KAFKA_PREFIX}_${agentId}`.replace(/@/g, "_").replace(/\|/g, "_");
5997
5780
  if (agentInstanceTelemetry.timer) {
5998
- this.#agentModel[agentId] = ObservabilityModelUtils.GetModelForAgent(agentId, agentInstanceTelemetry, subscribeToKafka, this.#options.logger);
5781
+ this.#agentModel[agentId] = ObservabilityModelUtils.GetModelForAgent(agentId, agentInstanceTelemetry, this.#options.logger);
5999
5782
  if (this.#agentModel[agentId] !== null) {
6000
- if (subscribeToKafka) {
6001
- this.#kafkaHelper.GetKafkaLogData(kafkaTopic, this.#agentModel[agentId]);
6002
- if (!this.FindSubscriptionByKey(kafkaTopic)) {
6003
- this.AddSubscriptions([{
6004
- subscriptionKey: {
6005
- id: v4(),
6006
- topic: SubscriptionTopic.LogProcessing,
6007
- key: kafkaTopic
6008
- },
6009
- cb: (payload) => {
6010
- this.#kafkaHelper.ProcessKafkaData(payload);
6011
- }
6012
- }]);
6013
- }
6014
- }
6015
5783
  } else {
6016
5784
  this.#LogDebugMessage(chalk.red(`CreateModelAgents():Error: GetModelForAgent() returned null`));
6017
5785
  }
6018
- } else {
6019
- if (subscribeToKafka) {
6020
- if (this.FindSubscriptionByKey(kafkaTopic)) {
6021
- this.RemoveSubscriptionsByKey(kafkaTopic);
6022
- }
6023
- }
6024
5786
  }
6025
5787
  }
6026
5788
  } catch (error) {
@@ -6028,43 +5790,21 @@ class ObservabilitySubscriptionManager {
6028
5790
  }
6029
5791
  }
6030
5792
  // /agentId/agentWorkerId
6031
- CreateModelAgentWorkers(subscriptionPayload, subscribeToKafka) {
5793
+ CreateModelAgentWorkers(subscriptionPayload) {
6032
5794
  try {
6033
5795
  this.#agentModel = {};
6034
5796
  for (const [agentId, agentWorker] of Object.entries(subscriptionPayload.data)) {
6035
5797
  for (const [agentWorkerId, agentInstanceTelemetry] of Object.entries(agentWorker)) {
6036
- const kafkaTopic = `${KAFKA_PREFIX}_${agentId}_${agentWorkerId}`.replace(/@/g, "_").replace(/\|/g, "_");
6037
5798
  if (agentInstanceTelemetry.timer) {
6038
5799
  const threadKey = `${agentWorkerId}`;
6039
- this.#agentModel[threadKey] = ObservabilityModelUtils.GetModelForAgent(threadKey, agentInstanceTelemetry, subscribeToKafka, this.#options.logger);
5800
+ this.#agentModel[threadKey] = ObservabilityModelUtils.GetModelForAgent(threadKey, agentInstanceTelemetry, this.#options.logger);
6040
5801
  if (this.#agentModel[threadKey] !== null) {
6041
5802
  const coreCount = this.#agentModel[threadKey].instruments[Gauge.CORE_COUNT_GAUGE].val;
6042
5803
  this.#agentModel[threadKey].canNavigate = coreCount > 0;
6043
5804
  this.#agentModel[threadKey].options = { agentId };
6044
- if (subscribeToKafka) {
6045
- this.#kafkaHelper.GetKafkaLogData(kafkaTopic, this.#agentModel[threadKey]);
6046
- if (!this.FindSubscriptionByKey(kafkaTopic)) {
6047
- this.AddSubscriptions([{
6048
- subscriptionKey: {
6049
- id: v4(),
6050
- topic: SubscriptionTopic.LogProcessing,
6051
- key: kafkaTopic
6052
- },
6053
- cb: (payload) => {
6054
- this.#kafkaHelper.ProcessKafkaData(payload);
6055
- }
6056
- }]);
6057
- }
6058
- }
6059
5805
  } else {
6060
5806
  this.#LogDebugMessage(chalk.red(`CreateModelAgentWorkers():Error: GetModelForAgent() returned null`));
6061
5807
  }
6062
- } else {
6063
- if (subscribeToKafka) {
6064
- if (this.FindSubscriptionByKey(kafkaTopic)) {
6065
- this.RemoveSubscriptionsByKey(kafkaTopic);
6066
- }
6067
- }
6068
5808
  }
6069
5809
  }
6070
5810
  }
@@ -6073,40 +5813,14 @@ class ObservabilitySubscriptionManager {
6073
5813
  }
6074
5814
  }
6075
5815
  // /agentId/agentWorkerId/asyncRunnerId
6076
- CreateModelAgentWorker(subscriptionPayload, subscribeToKafka) {
5816
+ CreateModelAgentWorker(subscriptionPayload) {
6077
5817
  try {
6078
5818
  this.#agentModel = {};
6079
5819
  for (const [agentId, agentWorker] of Object.entries(subscriptionPayload.data)) {
6080
5820
  for (const [agentWorkerId, asyncRunnerData] of Object.entries(agentWorker)) {
6081
5821
  for (const [asyncRunnerId, agentInstanceTelemetry] of Object.entries(asyncRunnerData)) {
6082
- const kafkaTopic = `${KAFKA_PREFIX}_${agentId}_${agentWorkerId}_${asyncRunnerId}`.replace(/@/g, "_").replace(/\|/g, "_");
6083
5822
  if (agentInstanceTelemetry.timer) {
6084
- this.#agentModel[asyncRunnerId] = ObservabilityModelUtils.GetModelForAgent(asyncRunnerId, agentInstanceTelemetry, subscribeToKafka, this.#options.logger);
6085
- if (this.#agentModel[asyncRunnerId] !== null) {
6086
- if (subscribeToKafka) {
6087
- this.#kafkaHelper.GetKafkaLogData(kafkaTopic, this.#agentModel[asyncRunnerId]);
6088
- if (!this.FindSubscriptionByKey(kafkaTopic)) {
6089
- this.AddSubscriptions([{
6090
- subscriptionKey: {
6091
- id: v4(),
6092
- topic: SubscriptionTopic.LogProcessing,
6093
- key: kafkaTopic
6094
- },
6095
- cb: (payload) => {
6096
- this.#kafkaHelper.ProcessKafkaData(payload);
6097
- }
6098
- }]);
6099
- }
6100
- }
6101
- } else {
6102
- this.#LogDebugMessage(chalk.red(`CreateModelAgentWorker():Error: GetModelForAgent() returned null`));
6103
- }
6104
- } else {
6105
- if (subscribeToKafka) {
6106
- if (this.FindSubscriptionByKey(kafkaTopic)) {
6107
- this.RemoveSubscriptionsByKey(kafkaTopic);
6108
- }
6109
- }
5823
+ this.#agentModel[asyncRunnerId] = ObservabilityModelUtils.GetModelForAgent(asyncRunnerId, agentInstanceTelemetry, this.#options.logger);
6110
5824
  }
6111
5825
  }
6112
5826
  }
@@ -6117,11 +5831,11 @@ class ObservabilitySubscriptionManager {
6117
5831
  }
6118
5832
  // --- [ Lambdas ] ------------------------------------------------------------------------------------------------------------------------------------------------
6119
5833
  // /
6120
- CreateModelAllLambdasCombined(subscriptionPayload, subscribeToKafka) {
5834
+ CreateModelAllLambdasCombined(subscriptionPayload) {
6121
5835
  try {
6122
5836
  this.#lambdaModel = {};
6123
5837
  if (subscriptionPayload.subscriptionKey.topic.localeCompare(SubscriptionTopic.AllLambdasCombined.toString()) === 0) {
6124
- this.#lambdaModel["STS-Lambda"] = ObservabilityModelUtils.GetModelForLambda("STS-Lambda", subscriptionPayload.data, subscribeToKafka, this.#options.logger);
5838
+ this.#lambdaModel["STS-Lambda"] = ObservabilityModelUtils.GetModelForLambda("STS-Lambda", subscriptionPayload.data, this.#options.logger);
6125
5839
  if (this.#lambdaModel["STS-Lambda"] === null) {
6126
5840
  this.#LogDebugMessage(chalk.red(`CreateModelAllLambdasCombined():Error: GetModelForLambda() returned null`));
6127
5841
  }
@@ -6132,11 +5846,11 @@ class ObservabilitySubscriptionManager {
6132
5846
  }
6133
5847
  }
6134
5848
  // /technologyId
6135
- CreateModelLambdaTechnologies(subscriptionPayload, subscribeToKafka) {
5849
+ CreateModelLambdaTechnologies(subscriptionPayload) {
6136
5850
  try {
6137
5851
  this.#lambdaModel = {};
6138
5852
  for (const [technologyId, technologyTelemetry] of Object.entries(subscriptionPayload.data)) {
6139
- this.#lambdaModel[technologyId] = ObservabilityModelUtils.GetModelForLambda(technologyId, technologyTelemetry, subscribeToKafka, this.#options.logger);
5853
+ this.#lambdaModel[technologyId] = ObservabilityModelUtils.GetModelForLambda(technologyId, technologyTelemetry, this.#options.logger);
6140
5854
  if (this.#lambdaModel[technologyId] === null) {
6141
5855
  this.#LogDebugMessage(chalk.red(`CreateModelLambdaTechnologies():Error: GetModelForLambda() returned null`));
6142
5856
  }
@@ -6146,40 +5860,18 @@ class ObservabilitySubscriptionManager {
6146
5860
  }
6147
5861
  }
6148
5862
  // /technologyId/subTechnologyId
6149
- CreateModelLambdaSubTechnologies(subscriptionPayload, subscribeToKafka) {
5863
+ CreateModelLambdaSubTechnologies(subscriptionPayload) {
6150
5864
  try {
6151
5865
  this.#lambdaModel = {};
6152
5866
  for (const [technologyId, technologyTelemetry] of Object.entries(subscriptionPayload.data)) {
6153
5867
  for (const [subTechnologyId, subTechnologyTelemetry] of Object.entries(technologyTelemetry)) {
6154
- const kafkaTopic = `${KAFKA_PREFIX}_${subTechnologyId}`.replace(/@/g, "_").replace(/\|/g, "_");
6155
5868
  if (subTechnologyTelemetry.cpu && subTechnologyTelemetry.cpu > 0) {
6156
- this.#lambdaModel[subTechnologyId] = ObservabilityModelUtils.GetModelForLambda(subTechnologyId, subTechnologyTelemetry, subscribeToKafka, this.#options.logger);
5869
+ this.#lambdaModel[subTechnologyId] = ObservabilityModelUtils.GetModelForLambda(subTechnologyId, subTechnologyTelemetry, this.#options.logger);
6157
5870
  if (this.#lambdaModel[subTechnologyId] !== null) {
6158
5871
  this.#lambdaModel[subTechnologyId].options = { technologyId };
6159
- if (subscribeToKafka) {
6160
- this.#kafkaHelper.GetKafkaLogData(kafkaTopic, this.#lambdaModel[subTechnologyId]);
6161
- if (!this.FindSubscriptionByKey(kafkaTopic)) {
6162
- this.AddSubscriptions([{
6163
- subscriptionKey: {
6164
- id: v4(),
6165
- topic: SubscriptionTopic.LogProcessing,
6166
- key: kafkaTopic
6167
- },
6168
- cb: (payload) => {
6169
- this.#kafkaHelper.ProcessKafkaData(payload);
6170
- }
6171
- }]);
6172
- }
6173
- }
6174
5872
  } else {
6175
5873
  this.#LogDebugMessage(chalk.red(`CreateModelLambdaSubTechnologies():Error: GetModelForLambda() returned null`));
6176
5874
  }
6177
- } else {
6178
- if (subscribeToKafka) {
6179
- if (this.FindSubscriptionByKey(kafkaTopic)) {
6180
- this.RemoveSubscriptionsByKey(kafkaTopic);
6181
- }
6182
- }
6183
5875
  }
6184
5876
  }
6185
5877
  }
@@ -6188,41 +5880,19 @@ class ObservabilitySubscriptionManager {
6188
5880
  }
6189
5881
  }
6190
5882
  // /technologyId/subTechnologyId/subTechnologyInstanceId
6191
- CreateModelLambdaSubTechnologiesInstance(subscriptionPayload, subscribeToKafka) {
5883
+ CreateModelLambdaSubTechnologiesInstance(subscriptionPayload) {
6192
5884
  try {
6193
5885
  this.#lambdaModel = {};
6194
5886
  for (const [technologyId, technologyTelemetry] of Object.entries(subscriptionPayload.data)) {
6195
5887
  for (const [subTechnologyId, subTechnologyTelemetry] of Object.entries(technologyTelemetry)) {
6196
5888
  for (const [subTechnologyInstanceId, subTechnologyInstanceTelemetry] of Object.entries(subTechnologyTelemetry)) {
6197
- const kafkaTopic = `${KAFKA_PREFIX}_${subTechnologyId}_${subTechnologyInstanceId}`.replace(/@/g, "_").replace(/\|/g, "_");
6198
5889
  if (subTechnologyInstanceTelemetry.cpu && subTechnologyInstanceTelemetry.cpu > 0) {
6199
- this.#lambdaModel[subTechnologyInstanceId] = ObservabilityModelUtils.GetModelForLambda(subTechnologyInstanceId, subTechnologyInstanceTelemetry, subscribeToKafka, this.#options.logger);
5890
+ this.#lambdaModel[subTechnologyInstanceId] = ObservabilityModelUtils.GetModelForLambda(subTechnologyInstanceId, subTechnologyInstanceTelemetry, this.#options.logger);
6200
5891
  if (this.#lambdaModel[subTechnologyInstanceId] !== null) {
6201
5892
  this.#lambdaModel[subTechnologyInstanceId].options = { technologyId, subTechnologyId };
6202
- if (subscribeToKafka) {
6203
- this.#kafkaHelper.GetKafkaLogData(kafkaTopic, this.#lambdaModel[subTechnologyInstanceId]);
6204
- if (!this.FindSubscriptionByKey(kafkaTopic)) {
6205
- this.AddSubscriptions([{
6206
- subscriptionKey: {
6207
- id: v4(),
6208
- topic: SubscriptionTopic.LogProcessing,
6209
- key: kafkaTopic
6210
- },
6211
- cb: (payload) => {
6212
- this.#kafkaHelper.ProcessKafkaData(payload);
6213
- }
6214
- }]);
6215
- }
6216
- }
6217
5893
  } else {
6218
5894
  this.#LogDebugMessage(chalk.red(`CreateModelLambdaSubTechnologiesInstance():Error: GetModelForLambda() returned null`));
6219
5895
  }
6220
- } else {
6221
- if (subscribeToKafka) {
6222
- if (this.FindSubscriptionByKey(kafkaTopic)) {
6223
- this.RemoveSubscriptionsByKey(kafkaTopic);
6224
- }
6225
- }
6226
5896
  }
6227
5897
  }
6228
5898
  }
@@ -6267,7 +5937,6 @@ export {
6267
5937
  InstrumentVelocityOptions,
6268
5938
  InstrumentVelocityTelemetry,
6269
5939
  KAFKA_PREFIX,
6270
- KafkaHelper,
6271
5940
  ObservabilityModelUtils,
6272
5941
  ObservabilityRESTAPISubscriber,
6273
5942
  ObservabilitySocketIOSubscriber,
@@ -6287,4 +5956,4 @@ export {
6287
5956
  runStates,
6288
5957
  useSTSInstrumentControllerPlugin
6289
5958
  };
6290
- //# sourceMappingURL=stsobservability.mjs.map
5959
+ //# sourceMappingURL=index.mjs.map