@nsshunt/stsobservability 1.0.41 → 1.0.45
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 +285 -346
- package/dist/stsobservability.mjs.map +1 -1
- package/dist/stsobservability.umd.js +286 -347
- package/dist/stsobservability.umd.js.map +1 -1
- package/package.json +10 -10
- package/types/publish/commonTypes.d.ts +12 -1
- package/types/publish/commonTypes.d.ts.map +1 -1
- package/types/publish/publishInstrumentController.d.ts +5 -4
- package/types/publish/publishInstrumentController.d.ts.map +1 -1
- package/types/publish/publishInstruments.d.ts +19 -0
- package/types/publish/publishInstruments.d.ts.map +1 -0
- package/types/publish/publishInstrumentsWebWorker.d.ts +2 -0
- package/types/publish/publishInstrumentsWebWorker.d.ts.map +1 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function(global2, factory) {
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("lodash.clonedeep"), require("detect-node"), require("@nsshunt/stsutils"), require("tiny-emitter"), require("
|
|
3
|
-
})(this, function(exports2, _cloneDeep, isNode, stsutils, tinyEmitter,
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("lodash.clonedeep"), require("detect-node"), require("@nsshunt/stsutils"), require("tiny-emitter"), require("node:https"), require("axios"), require("vue"), require("socket.io-client")) : typeof define === "function" && define.amd ? define(["exports", "lodash.clonedeep", "detect-node", "@nsshunt/stsutils", "tiny-emitter", "node:https", "axios", "vue", "socket.io-client"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2["@nsshunt/stsobservability"] = {}, global2.lodash, global2["detect-node"], global2.stsutils, global2["tiny-emitter"], global2.https, global2.axios, global2.vue, global2.socket["io-client"]));
|
|
3
|
+
})(this, function(exports2, _cloneDeep, isNode, stsutils, tinyEmitter, https, axios, vue, socket_ioClient) {
|
|
4
4
|
"use strict";var __defProp = Object.defineProperty;
|
|
5
5
|
var __typeError = (msg) => {
|
|
6
6
|
throw TypeError(msg);
|
|
@@ -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,
|
|
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, _worker, _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;
|
|
25
25
|
var Gauge = /* @__PURE__ */ ((Gauge2) => {
|
|
26
26
|
Gauge2["ACTIVE_REQUEST_GAUGE"] = "a";
|
|
27
27
|
Gauge2["AUTHENTICATION_COUNT_GAUGE"] = "b";
|
|
@@ -3894,343 +3894,6 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3894
3894
|
chalk.stderr.supportsColor = stderrColor;
|
|
3895
3895
|
var source = chalk;
|
|
3896
3896
|
const chalk$1 = /* @__PURE__ */ getDefaultExportFromCjs(source);
|
|
3897
|
-
var ePublishState = /* @__PURE__ */ ((ePublishState2) => {
|
|
3898
|
-
ePublishState2[ePublishState2["init"] = 0] = "init";
|
|
3899
|
-
ePublishState2[ePublishState2["started"] = 1] = "started";
|
|
3900
|
-
ePublishState2[ePublishState2["stopping"] = 2] = "stopping";
|
|
3901
|
-
return ePublishState2;
|
|
3902
|
-
})(ePublishState || {});
|
|
3903
|
-
const _PublishInstrumentController = class _PublishInstrumentController extends stsutils.STSOptionsBase {
|
|
3904
|
-
constructor(options) {
|
|
3905
|
-
super(options);
|
|
3906
|
-
__privateAdd(this, _PublishInstrumentController_instances);
|
|
3907
|
-
__privateAdd(this, _instruments, {});
|
|
3908
|
-
__privateAdd(this, _inPublish, false);
|
|
3909
|
-
__privateAdd(this, _observer2, null);
|
|
3910
|
-
__privateAdd(this, _publishState, 0);
|
|
3911
|
-
__publicField(this, "LogEx", (message) => {
|
|
3912
|
-
this.UpdateInstrument(Gauge.LOGGER, {
|
|
3913
|
-
LogMessage: message
|
|
3914
|
-
});
|
|
3915
|
-
});
|
|
3916
|
-
__privateMethod(this, _PublishInstrumentController_instances, UpdateState_fn).call(this, 0, "constructor()");
|
|
3917
|
-
this.SetupInstrumentation();
|
|
3918
|
-
this.StartPublish();
|
|
3919
|
-
}
|
|
3920
|
-
get options() {
|
|
3921
|
-
return super.options;
|
|
3922
|
-
}
|
|
3923
|
-
async Publish() {
|
|
3924
|
-
if (__privateGet(this, _inPublish)) {
|
|
3925
|
-
return false;
|
|
3926
|
-
}
|
|
3927
|
-
try {
|
|
3928
|
-
__privateSet(this, _inPublish, true);
|
|
3929
|
-
if (Object.keys(__privateGet(this, _instruments)).length > 0) {
|
|
3930
|
-
const instrumentPayload = __privateMethod(this, _PublishInstrumentController_instances, GetPayloadData_fn).call(this, this.options.processContext, __privateGet(this, _instruments));
|
|
3931
|
-
return await this.options.publisherTransport.Publish(instrumentPayload);
|
|
3932
|
-
} else {
|
|
3933
|
-
return true;
|
|
3934
|
-
}
|
|
3935
|
-
} catch (error) {
|
|
3936
|
-
return false;
|
|
3937
|
-
} finally {
|
|
3938
|
-
__privateSet(this, _inPublish, false);
|
|
3939
|
-
}
|
|
3940
|
-
}
|
|
3941
|
-
async StartPublish() {
|
|
3942
|
-
if (__privateGet(this, _publishState) !== 0) {
|
|
3943
|
-
this.options.logger.debug(chalk$1.yellow(`StartPublish:${this.options.processContext.nid}: StartPublish called when not currently in the init state. Current State: [${__privateGet(this, _publishState)}]`));
|
|
3944
|
-
return false;
|
|
3945
|
-
}
|
|
3946
|
-
__privateMethod(this, _PublishInstrumentController_instances, UpdateState_fn).call(this, 1, "StartPublish()");
|
|
3947
|
-
__privateMethod(this, _PublishInstrumentController_instances, PublishTimeoutLoop_fn).call(this, this.options.publishInterval);
|
|
3948
|
-
return true;
|
|
3949
|
-
}
|
|
3950
|
-
async EndPublish() {
|
|
3951
|
-
if (__privateGet(this, _publishState) !== 1) {
|
|
3952
|
-
this.options.logger.debug(chalk$1.yellow(`EndPublish:${this.options.processContext.nid}: EndPublish called when not within the started state. Current State: [${__privateGet(this, _publishState)}]`));
|
|
3953
|
-
return false;
|
|
3954
|
-
}
|
|
3955
|
-
__privateMethod(this, _PublishInstrumentController_instances, UpdateState_fn).call(this, 2, "EndPublish() (1)");
|
|
3956
|
-
if (__privateGet(this, _observer2) !== null) {
|
|
3957
|
-
clearInterval(__privateGet(this, _observer2));
|
|
3958
|
-
__privateSet(this, _observer2, null);
|
|
3959
|
-
await this.Publish();
|
|
3960
|
-
}
|
|
3961
|
-
await this.options.publisherTransport.Close();
|
|
3962
|
-
__privateMethod(this, _PublishInstrumentController_instances, UpdateState_fn).call(this, 0, "EndPublish() (2)");
|
|
3963
|
-
return true;
|
|
3964
|
-
}
|
|
3965
|
-
SetupInstrumentation() {
|
|
3966
|
-
if (!this.options.instrumentDefinitions) {
|
|
3967
|
-
this.options.logger.debug(chalk$1.yellow(`SetupInstrumentation:${this.options.processContext.nid}: No instrument(s) defined within supplied options.`));
|
|
3968
|
-
return;
|
|
3969
|
-
}
|
|
3970
|
-
if (!this.options.processContext) {
|
|
3971
|
-
this.options.logger.debug(chalk$1.yellow(`SetupInstrumentation: No context defined within supplied options.`));
|
|
3972
|
-
return;
|
|
3973
|
-
}
|
|
3974
|
-
__privateMethod(this, _PublishInstrumentController_instances, CreateInstruments_fn).call(this, this.options.instrumentDefinitions);
|
|
3975
|
-
}
|
|
3976
|
-
/**
|
|
3977
|
-
* Check if an instrument exists within the managed instrument collection
|
|
3978
|
-
* @param instrumentName
|
|
3979
|
-
* @returns
|
|
3980
|
-
*/
|
|
3981
|
-
InstrumentExists(instrumentName) {
|
|
3982
|
-
if (__privateGet(this, _instruments)[instrumentName]) {
|
|
3983
|
-
return true;
|
|
3984
|
-
}
|
|
3985
|
-
return false;
|
|
3986
|
-
}
|
|
3987
|
-
/**
|
|
3988
|
-
* Update instrument telemetry.
|
|
3989
|
-
* @param instrumentName
|
|
3990
|
-
* @param telemetry
|
|
3991
|
-
*/
|
|
3992
|
-
UpdateInstrument(instrumentName, telemetry) {
|
|
3993
|
-
if (__privateGet(this, _instruments)[instrumentName]) {
|
|
3994
|
-
__privateMethod(this, _PublishInstrumentController_instances, ProcessTelemetryCommand_fn).call(this, instrumentName, telemetry);
|
|
3995
|
-
} else {
|
|
3996
|
-
this.options.logger.debug(chalk$1.red(`UpdateInstrument:${this.options.processContext.nid}: Attempted to UpdateInstrument before initialised.`));
|
|
3997
|
-
}
|
|
3998
|
-
}
|
|
3999
|
-
/**
|
|
4000
|
-
* Add additional instrument publishers. Usually invoked when adding workers to the app and/or async runners within a worker.
|
|
4001
|
-
* @param processContext
|
|
4002
|
-
* @returns Returns the newly created PublishInstrumentController
|
|
4003
|
-
*/
|
|
4004
|
-
AddPublishInstrumentController(processContext) {
|
|
4005
|
-
const options = { ...this.options };
|
|
4006
|
-
options.processContext = processContext;
|
|
4007
|
-
return new _PublishInstrumentController(options);
|
|
4008
|
-
}
|
|
4009
|
-
/*
|
|
4010
|
-
#GetHttpAgentInstruments(): InstrumentDefinitions {
|
|
4011
|
-
if (isNode) {
|
|
4012
|
-
return [ ];
|
|
4013
|
-
} else {
|
|
4014
|
-
return [
|
|
4015
|
-
[ Gauge.REQUEST_COUNT_GAUGE, GaugeTypes.INSTRUMENT_GAUGE ], // Total number of requests serviced
|
|
4016
|
-
[ Gauge.ERROR_COUNT_GAUGE, GaugeTypes.INSTRUMENT_GAUGE ],
|
|
4017
|
-
[ Gauge.RETRY_COUNT_GAUGE, GaugeTypes.INSTRUMENT_GAUGE ],
|
|
4018
|
-
[ Gauge.AUTHENTICATION_COUNT_GAUGE, GaugeTypes.INSTRUMENT_GAUGE ], // Total number of new token requests
|
|
4019
|
-
[ Gauge.AUTHENTICATION_ERROR_COUNT_GAUGE, GaugeTypes.INSTRUMENT_GAUGE ], // Total number of new token requests errors
|
|
4020
|
-
[ Gauge.AUTHENTICATION_RETRY_COUNT_GAUGE, GaugeTypes.INSTRUMENT_GAUGE ], // Total number of new token requests retries
|
|
4021
|
-
[ Gauge.ACTIVE_REQUEST_GAUGE, GaugeTypes.INSTRUMENT_GAUGE, { // Total number of runners (in-flight) requests
|
|
4022
|
-
interval: this.options.instrumentationObservationInterval,
|
|
4023
|
-
sampleSize: this.options.instrumentationTimeWindow } as InstrumentGaugeOptions],
|
|
4024
|
-
[ Gauge.DURATION_GAUGE, GaugeTypes.INSTRUMENT_GAUGE, { // Duration of latest http(s) request.
|
|
4025
|
-
interval: this.options.instrumentationObservationInterval,
|
|
4026
|
-
sampleSize: this.options.instrumentationTimeWindow } as InstrumentGaugeOptions],
|
|
4027
|
-
[ Gauge.DURATION_HISTOGRAM_GAUGE, GaugeTypes.INSTRUMENT_HISTOGRAM ],
|
|
4028
|
-
[ Gauge.VELOCITY_GAUGE, GaugeTypes.INSTRUMENT_VELOCITY ], // Requests per second
|
|
4029
|
-
[ Gauge.CORE_COUNT_GAUGE, GaugeTypes.INSTRUMENT_GAUGE ], // Thread count (for http agents)
|
|
4030
|
-
[ Gauge.LATENCY_GAUGE, GaugeTypes.INSTRUMENT_GAUGE, {
|
|
4031
|
-
interval: this.options.instrumentationObservationInterval,
|
|
4032
|
-
sampleSize: this.options.instrumentationTimeWindow } as InstrumentGaugeOptions],
|
|
4033
|
-
[ Gauge.LATENCY_HISTOGRAM_GAUGE, GaugeTypes.INSTRUMENT_HISTOGRAM ],
|
|
4034
|
-
[ Gauge.CHILD_COUNT, GaugeTypes.INSTRUMENT_GAUGE ], // Number of async runners idle or running
|
|
4035
|
-
]
|
|
4036
|
-
}
|
|
4037
|
-
}
|
|
4038
|
-
*/
|
|
4039
|
-
/*
|
|
4040
|
-
#GetHttpNodeServerInstruments(): InstrumentDefinitions {
|
|
4041
|
-
if (isNode) {
|
|
4042
|
-
if (this.options.httpServer === true) {
|
|
4043
|
-
return [
|
|
4044
|
-
[ Gauge.REQUEST_COUNT_GAUGE, GaugeTypes.INSTRUMENT_GAUGE ], // Total number of requests serviced
|
|
4045
|
-
[ Gauge.AUTHENTICATION_COUNT_GAUGE, GaugeTypes.INSTRUMENT_GAUGE ], // Total number of new token requests
|
|
4046
|
-
[ Gauge.AUTHENTICATION_ERROR_COUNT_GAUGE, GaugeTypes.INSTRUMENT_GAUGE ], // Total number of new token requests errors
|
|
4047
|
-
[ Gauge.AUTHENTICATION_RETRY_COUNT_GAUGE, GaugeTypes.INSTRUMENT_GAUGE ], // Total number of new token requests retries
|
|
4048
|
-
|
|
4049
|
-
[ Gauge.ACTIVE_REQUEST_GAUGE, GaugeTypes.INSTRUMENT_GAUGE, {
|
|
4050
|
-
interval: this.options.instrumentationObservationInterval,
|
|
4051
|
-
sampleSize: this.options.instrumentationTimeWindow } as InstrumentGaugeOptions],
|
|
4052
|
-
[ Gauge.DURATION_GAUGE, GaugeTypes.INSTRUMENT_GAUGE, {
|
|
4053
|
-
interval: this.options.instrumentationObservationInterval,
|
|
4054
|
-
sampleSize: this.options.instrumentationTimeWindow } as InstrumentGaugeOptions],
|
|
4055
|
-
[ Gauge.DURATION_HISTOGRAM_GAUGE, GaugeTypes.INSTRUMENT_HISTOGRAM ],
|
|
4056
|
-
[ Gauge.CONNECTION_COUNT_GAUGE, GaugeTypes.INSTRUMENT_GAUGE, {
|
|
4057
|
-
interval: this.options.instrumentationObservationInterval,
|
|
4058
|
-
sampleSize: this.options.instrumentationTimeWindow } as InstrumentGaugeOptions],
|
|
4059
|
-
|
|
4060
|
-
[ Gauge.CONNECTION_POOL_TOTAL_GAUGE, GaugeTypes.INSTRUMENT_GAUGE ],
|
|
4061
|
-
[ Gauge.CONNECTION_POOL_IDLE_GAUGE, GaugeTypes.INSTRUMENT_GAUGE ],
|
|
4062
|
-
[ Gauge.CONNECTION_POOL_WAITING_GAUGE, GaugeTypes.INSTRUMENT_GAUGE ],
|
|
4063
|
-
[ Gauge.VELOCITY_GAUGE, GaugeTypes.INSTRUMENT_VELOCITY ], // Requests per second
|
|
4064
|
-
[ Gauge.ERROR_COUNT_GAUGE, GaugeTypes.INSTRUMENT_GAUGE ],
|
|
4065
|
-
[ Gauge.RETRY_COUNT_GAUGE, GaugeTypes.INSTRUMENT_GAUGE ],
|
|
4066
|
-
[ Gauge.LATENCY_GAUGE, GaugeTypes.INSTRUMENT_GAUGE, {
|
|
4067
|
-
interval: this.options.instrumentationObservationInterval,
|
|
4068
|
-
sampleSize: this.options.instrumentationTimeWindow } as InstrumentGaugeOptions],
|
|
4069
|
-
[ Gauge.LATENCY_HISTOGRAM_GAUGE, GaugeTypes.INSTRUMENT_HISTOGRAM ],
|
|
4070
|
-
[ Gauge.CORE_COUNT_GAUGE, GaugeTypes.INSTRUMENT_GAUGE ]
|
|
4071
|
-
]
|
|
4072
|
-
} else {
|
|
4073
|
-
return [ ];
|
|
4074
|
-
}
|
|
4075
|
-
} else {
|
|
4076
|
-
return [ ];
|
|
4077
|
-
}
|
|
4078
|
-
}
|
|
4079
|
-
*/
|
|
4080
|
-
/*
|
|
4081
|
-
#GetAdditionalInstruments(): InstrumentDefinitions {
|
|
4082
|
-
if (this.options.instrumentDefinitions) {
|
|
4083
|
-
return this.options.instrumentDefinitions;
|
|
4084
|
-
} else {
|
|
4085
|
-
return [ ];
|
|
4086
|
-
}
|
|
4087
|
-
}
|
|
4088
|
-
*/
|
|
4089
|
-
/*
|
|
4090
|
-
#SetupInstruments() {
|
|
4091
|
-
this.options.logger.debug(chalk.yellow(`#SetupInstruments:${this.options.processContext.nid}: Started`));
|
|
4092
|
-
|
|
4093
|
-
const standardInstruments: InstrumentDefinitions = [
|
|
4094
|
-
[ Gauge.TIMER_GAUGE, GaugeTypes.INSTRUMENT_TIMER ],
|
|
4095
|
-
[ Gauge.LOGGER, GaugeTypes.INSTRUMENT_LOG, {
|
|
4096
|
-
consoleLogging: this.options.consoleLogging,
|
|
4097
|
-
instrumentLogging: this.options.instrumentLogging } as InstrumentLogOptions],
|
|
4098
|
-
[ Gauge.NETWORK_RX_GAUGE , GaugeTypes.INSTRUMENT_VELOCITY ],
|
|
4099
|
-
[ Gauge.NETWORK_TX_GAUGE, GaugeTypes.INSTRUMENT_VELOCITY ]
|
|
4100
|
-
];
|
|
4101
|
-
|
|
4102
|
-
let nodeStandardInstruments: InstrumentDefinitions = [ ];
|
|
4103
|
-
if (isNode) {
|
|
4104
|
-
nodeStandardInstruments = [
|
|
4105
|
-
[ Gauge.CPU_LOAD_GAUGE, GaugeTypes.INSTRUMENT_GAUGE, {
|
|
4106
|
-
interval: this.options.instrumentationObservationInterval,
|
|
4107
|
-
sampleSize: this.options.instrumentationTimeWindow } as InstrumentGaugeOptions],
|
|
4108
|
-
[ Gauge.OBJECT_GAUGE, GaugeTypes.INSTRUMENT_OBJECT, {
|
|
4109
|
-
label:'InstrumentObjectMaster' } as InstrumentObjectOptions]
|
|
4110
|
-
];
|
|
4111
|
-
}
|
|
4112
|
-
|
|
4113
|
-
const instruments: InstrumentDefinitions = [
|
|
4114
|
-
...standardInstruments,
|
|
4115
|
-
...nodeStandardInstruments,
|
|
4116
|
-
...this.#GetHttpAgentInstruments(),
|
|
4117
|
-
...this.#GetHttpNodeServerInstruments(),
|
|
4118
|
-
...this.#GetAdditionalInstruments()
|
|
4119
|
-
]
|
|
4120
|
-
|
|
4121
|
-
this.options.logger.debug(chalk.green(`#SetupInstruments:${this.options.processContext.nid}: Completed`));
|
|
4122
|
-
}
|
|
4123
|
-
*/
|
|
4124
|
-
};
|
|
4125
|
-
_instruments = new WeakMap();
|
|
4126
|
-
_inPublish = new WeakMap();
|
|
4127
|
-
_observer2 = new WeakMap();
|
|
4128
|
-
_publishState = new WeakMap();
|
|
4129
|
-
_PublishInstrumentController_instances = new WeakSet();
|
|
4130
|
-
GetInstrument_fn = function(instrumentName) {
|
|
4131
|
-
return __privateGet(this, _instruments)[instrumentName];
|
|
4132
|
-
};
|
|
4133
|
-
ProcessTelemetryCommand_fn = function(instrumentName, telemetry) {
|
|
4134
|
-
const instrument = __privateMethod(this, _PublishInstrumentController_instances, GetInstrument_fn).call(this, instrumentName);
|
|
4135
|
-
if (instrument) {
|
|
4136
|
-
instrument.ProcessTelemetry(telemetry);
|
|
4137
|
-
}
|
|
4138
|
-
};
|
|
4139
|
-
// Instrument factory
|
|
4140
|
-
CreateInstrument_fn = function(instrumentType, options) {
|
|
4141
|
-
let instrument;
|
|
4142
|
-
switch (instrumentType) {
|
|
4143
|
-
case GaugeTypes.INSTRUMENT_GAUGE:
|
|
4144
|
-
instrument = new InstrumentGauge(options);
|
|
4145
|
-
break;
|
|
4146
|
-
case GaugeTypes.INSTRUMENT_HISTOGRAM:
|
|
4147
|
-
instrument = new InstrumentHistogram(options);
|
|
4148
|
-
break;
|
|
4149
|
-
case GaugeTypes.INSTRUMENT_LOG:
|
|
4150
|
-
instrument = new InstrumentLog(options);
|
|
4151
|
-
break;
|
|
4152
|
-
case GaugeTypes.INSTRUMENT_OBJECT:
|
|
4153
|
-
instrument = new InstrumentObject(options);
|
|
4154
|
-
break;
|
|
4155
|
-
case GaugeTypes.INSTRUMENT_TIMER:
|
|
4156
|
-
instrument = new InstrumentTimerGauge(options);
|
|
4157
|
-
break;
|
|
4158
|
-
case GaugeTypes.INSTRUMENT_VELOCITY:
|
|
4159
|
-
instrument = new InstrumentVelocity(options);
|
|
4160
|
-
break;
|
|
4161
|
-
default:
|
|
4162
|
-
throw new Error(`Gauge type: [${instrumentType} not known.]`);
|
|
4163
|
-
}
|
|
4164
|
-
return instrument;
|
|
4165
|
-
};
|
|
4166
|
-
CreateInstruments_fn = function(payload) {
|
|
4167
|
-
payload.forEach((instrumentDefinition) => {
|
|
4168
|
-
const g = instrumentDefinition[0];
|
|
4169
|
-
const gt = instrumentDefinition[1];
|
|
4170
|
-
const instrumentBaseOptions = instrumentDefinition[2];
|
|
4171
|
-
const instrument = __privateMethod(this, _PublishInstrumentController_instances, CreateInstrument_fn).call(this, gt, instrumentBaseOptions);
|
|
4172
|
-
__privateGet(this, _instruments)[g] = instrument;
|
|
4173
|
-
});
|
|
4174
|
-
};
|
|
4175
|
-
GetPayloadData_fn = function(context, instruments) {
|
|
4176
|
-
const payloadInstruments = {};
|
|
4177
|
-
for (const [key, value] of Object.entries(instruments)) {
|
|
4178
|
-
if (value instanceof InstrumentLog) {
|
|
4179
|
-
payloadInstruments[key] = { ...value.WithUseLatestMessages(true) };
|
|
4180
|
-
} else {
|
|
4181
|
-
payloadInstruments[key] = { ...value };
|
|
4182
|
-
}
|
|
4183
|
-
}
|
|
4184
|
-
return {
|
|
4185
|
-
context,
|
|
4186
|
-
instruments: payloadInstruments
|
|
4187
|
-
};
|
|
4188
|
-
};
|
|
4189
|
-
PublishTimeoutLoop_fn = function(publishInterval) {
|
|
4190
|
-
__privateSet(this, _observer2, setTimeout(async () => {
|
|
4191
|
-
const start = performance.now();
|
|
4192
|
-
await this.Publish();
|
|
4193
|
-
const end = performance.now();
|
|
4194
|
-
const diff = end - start;
|
|
4195
|
-
if (__privateGet(this, _publishState) === 1) {
|
|
4196
|
-
__privateMethod(this, _PublishInstrumentController_instances, PublishTimeoutLoop_fn).call(this, this.options.publishInterval - diff);
|
|
4197
|
-
}
|
|
4198
|
-
}, publishInterval));
|
|
4199
|
-
if (isNode) __privateGet(this, _observer2).unref();
|
|
4200
|
-
};
|
|
4201
|
-
UpdateState_fn = function(newState, comment) {
|
|
4202
|
-
const previousState = __privateGet(this, _publishState);
|
|
4203
|
-
__privateSet(this, _publishState, newState);
|
|
4204
|
-
this.options.logger.debug(chalk$1.yellow(`#UpdateState:${this.options.processContext.nid}: Previous State: [${previousState}]. Current State: [${__privateGet(this, _publishState)}]. Comment: [${comment}]`));
|
|
4205
|
-
};
|
|
4206
|
-
let PublishInstrumentController = _PublishInstrumentController;
|
|
4207
|
-
const STSInstrumentControllerPluginKey = Symbol("instrumentController");
|
|
4208
|
-
const GetSTSInstrumentControllerPluginKey = () => STSInstrumentControllerPluginKey;
|
|
4209
|
-
const CompareSTSInstrumentControllerPluginKey = (val) => val === STSInstrumentControllerPluginKey;
|
|
4210
|
-
const useSTSInstrumentControllerPlugin = () => vue.inject(STSInstrumentControllerPluginKey);
|
|
4211
|
-
const GetSTSInstrumentController = (app) => {
|
|
4212
|
-
return app.config.globalProperties.$sts[STSInstrumentControllerPluginKey];
|
|
4213
|
-
};
|
|
4214
|
-
const STSInstrumentControllerPlugin = {
|
|
4215
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4216
|
-
install: (app, options) => {
|
|
4217
|
-
options.logger.debug(chalk$1.yellow(`STSInstrumentControllerPlugin:install:Start`));
|
|
4218
|
-
const aic = new PublishInstrumentController(options);
|
|
4219
|
-
if (!app.config.globalProperties.$sts) {
|
|
4220
|
-
options.logger.debug(chalk$1.cyan(`STSInstrumentControllerPlugin:install: [app.config.globalProperties.$sts] does not exist.`));
|
|
4221
|
-
app.config.globalProperties.$sts = {};
|
|
4222
|
-
options.logger.debug(chalk$1.cyan(`STSInstrumentControllerPlugin:install: created empty [app.config.globalProperties.$sts].`));
|
|
4223
|
-
} else {
|
|
4224
|
-
options.logger.debug(chalk$1.cyan(`STSInstrumentControllerPlugin:install: [app.config.globalProperties.$sts] already exists.`));
|
|
4225
|
-
}
|
|
4226
|
-
app.config.globalProperties.$sts.aic = aic;
|
|
4227
|
-
app.config.globalProperties.$sts[STSInstrumentControllerPluginKey] = aic;
|
|
4228
|
-
options.logger.debug(chalk$1.cyan(`STSInstrumentControllerPlugin:install: AgentInstrumentController installed into [app.config.globalProperties.$sts] using: [${String(STSInstrumentControllerPluginKey)}].`));
|
|
4229
|
-
app.provide(STSInstrumentControllerPluginKey, aic);
|
|
4230
|
-
options.logger.debug(chalk$1.cyan(`STSInstrumentControllerPlugin:install: AgentInstrumentController installed into 'provide' using: [${String(STSInstrumentControllerPluginKey)}].`));
|
|
4231
|
-
options.logger.debug(chalk$1.green(`STSInstrumentControllerPlugin:install:End`));
|
|
4232
|
-
}
|
|
4233
|
-
};
|
|
4234
3897
|
function utf8Count(str) {
|
|
4235
3898
|
var strLength = str.length;
|
|
4236
3899
|
var byteLength = 0;
|
|
@@ -4959,6 +4622,289 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
4959
4622
|
}
|
|
4960
4623
|
}
|
|
4961
4624
|
_httpsAgent = new WeakMap();
|
|
4625
|
+
class PublishInstruments extends stsutils.STSOptionsBase {
|
|
4626
|
+
constructor(options) {
|
|
4627
|
+
super(options);
|
|
4628
|
+
__privateAdd(this, _PublishInstruments_instances);
|
|
4629
|
+
__privateAdd(this, _inPublish, false);
|
|
4630
|
+
__privateAdd(this, _observer2, null);
|
|
4631
|
+
__privateAdd(this, _publishState, 0);
|
|
4632
|
+
__privateAdd(this, _publisherTransport, null);
|
|
4633
|
+
__privateSet(this, _publisherTransport, null);
|
|
4634
|
+
switch (options.publishTransportBaseOptions.transportType) {
|
|
4635
|
+
case TransportType.RESTAPI:
|
|
4636
|
+
__privateSet(this, _publisherTransport, new PublishTransportRESTServer(options.publishTransportBaseOptions));
|
|
4637
|
+
break;
|
|
4638
|
+
}
|
|
4639
|
+
__privateMethod(this, _PublishInstruments_instances, UpdateState_fn).call(this, 0, "constructor()");
|
|
4640
|
+
}
|
|
4641
|
+
get options() {
|
|
4642
|
+
return super.options;
|
|
4643
|
+
}
|
|
4644
|
+
async Publish() {
|
|
4645
|
+
if (__privateGet(this, _inPublish)) {
|
|
4646
|
+
return false;
|
|
4647
|
+
}
|
|
4648
|
+
if (__privateGet(this, _publisherTransport)) {
|
|
4649
|
+
try {
|
|
4650
|
+
__privateSet(this, _inPublish, true);
|
|
4651
|
+
const instrumentPayload = this.options.publishInstrumentController.GetPayloadData();
|
|
4652
|
+
return await __privateGet(this, _publisherTransport).Publish(instrumentPayload);
|
|
4653
|
+
} catch (error) {
|
|
4654
|
+
return false;
|
|
4655
|
+
} finally {
|
|
4656
|
+
__privateSet(this, _inPublish, false);
|
|
4657
|
+
}
|
|
4658
|
+
} else {
|
|
4659
|
+
return false;
|
|
4660
|
+
}
|
|
4661
|
+
}
|
|
4662
|
+
async StartPublish() {
|
|
4663
|
+
if (__privateGet(this, _publishState) !== 0) {
|
|
4664
|
+
this.options.logger.debug(chalk$1.yellow(`StartPublish:${this.options.processContext.nid}: StartPublish called when not currently in the init state. Current State: [${__privateGet(this, _publishState)}]`));
|
|
4665
|
+
return false;
|
|
4666
|
+
}
|
|
4667
|
+
__privateMethod(this, _PublishInstruments_instances, UpdateState_fn).call(this, 1, "StartPublish()");
|
|
4668
|
+
__privateMethod(this, _PublishInstruments_instances, PublishTimeoutLoop_fn).call(this, this.options.publishInterval);
|
|
4669
|
+
return true;
|
|
4670
|
+
}
|
|
4671
|
+
async EndPublish() {
|
|
4672
|
+
if (__privateGet(this, _publishState) !== 1) {
|
|
4673
|
+
this.options.logger.debug(chalk$1.yellow(`EndPublish:${this.options.processContext.nid}: EndPublish called when not within the started state. Current State: [${__privateGet(this, _publishState)}]`));
|
|
4674
|
+
return false;
|
|
4675
|
+
}
|
|
4676
|
+
__privateMethod(this, _PublishInstruments_instances, UpdateState_fn).call(this, 2, "EndPublish() (1)");
|
|
4677
|
+
if (__privateGet(this, _observer2) !== null) {
|
|
4678
|
+
clearInterval(__privateGet(this, _observer2));
|
|
4679
|
+
__privateSet(this, _observer2, null);
|
|
4680
|
+
await this.Publish();
|
|
4681
|
+
}
|
|
4682
|
+
if (__privateGet(this, _publisherTransport)) {
|
|
4683
|
+
await __privateGet(this, _publisherTransport).Close();
|
|
4684
|
+
}
|
|
4685
|
+
__privateMethod(this, _PublishInstruments_instances, UpdateState_fn).call(this, 0, "EndPublish() (2)");
|
|
4686
|
+
return true;
|
|
4687
|
+
}
|
|
4688
|
+
}
|
|
4689
|
+
_inPublish = new WeakMap();
|
|
4690
|
+
_observer2 = new WeakMap();
|
|
4691
|
+
_publishState = new WeakMap();
|
|
4692
|
+
_publisherTransport = new WeakMap();
|
|
4693
|
+
_PublishInstruments_instances = new WeakSet();
|
|
4694
|
+
PublishTimeoutLoop_fn = function(publishInterval) {
|
|
4695
|
+
__privateSet(this, _observer2, setTimeout(async () => {
|
|
4696
|
+
const start = performance.now();
|
|
4697
|
+
await this.Publish();
|
|
4698
|
+
const end = performance.now();
|
|
4699
|
+
const diff = end - start;
|
|
4700
|
+
if (__privateGet(this, _publishState) === 1) {
|
|
4701
|
+
__privateMethod(this, _PublishInstruments_instances, PublishTimeoutLoop_fn).call(this, this.options.publishInterval - diff);
|
|
4702
|
+
}
|
|
4703
|
+
}, publishInterval));
|
|
4704
|
+
if (isNode) __privateGet(this, _observer2).unref();
|
|
4705
|
+
};
|
|
4706
|
+
UpdateState_fn = function(newState, comment) {
|
|
4707
|
+
const previousState = __privateGet(this, _publishState);
|
|
4708
|
+
__privateSet(this, _publishState, newState);
|
|
4709
|
+
this.options.logger.debug(chalk$1.yellow(`#UpdateState:${this.options.processContext.nid}: Previous State: [${previousState}]. Current State: [${__privateGet(this, _publishState)}]. Comment: [${comment}]`));
|
|
4710
|
+
};
|
|
4711
|
+
var ePublishState = /* @__PURE__ */ ((ePublishState2) => {
|
|
4712
|
+
ePublishState2[ePublishState2["init"] = 0] = "init";
|
|
4713
|
+
ePublishState2[ePublishState2["started"] = 1] = "started";
|
|
4714
|
+
ePublishState2[ePublishState2["stopping"] = 2] = "stopping";
|
|
4715
|
+
return ePublishState2;
|
|
4716
|
+
})(ePublishState || {});
|
|
4717
|
+
const _PublishInstrumentController = class _PublishInstrumentController extends stsutils.STSOptionsBase {
|
|
4718
|
+
constructor(options) {
|
|
4719
|
+
super(options);
|
|
4720
|
+
__privateAdd(this, _PublishInstrumentController_instances);
|
|
4721
|
+
__privateAdd(this, _instruments, {});
|
|
4722
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4723
|
+
__privateAdd(this, _worker);
|
|
4724
|
+
// Worker
|
|
4725
|
+
__privateAdd(this, _publisher, null);
|
|
4726
|
+
__publicField(this, "LogEx", (message) => {
|
|
4727
|
+
this.UpdateInstrument(Gauge.LOGGER, {
|
|
4728
|
+
LogMessage: message
|
|
4729
|
+
});
|
|
4730
|
+
});
|
|
4731
|
+
this.SetupInstrumentation();
|
|
4732
|
+
if (this.options.CreateWorkerFactory) {
|
|
4733
|
+
__privateSet(this, _worker, this.options.CreateWorkerFactory());
|
|
4734
|
+
} else {
|
|
4735
|
+
const publishInstrumentsOptions = {
|
|
4736
|
+
logger: options.logger,
|
|
4737
|
+
processContext: options.processContext,
|
|
4738
|
+
publishInterval: options.publishInterval,
|
|
4739
|
+
publishInstrumentController: this,
|
|
4740
|
+
publishTransportBaseOptions: options.publishTransportBaseOptions
|
|
4741
|
+
};
|
|
4742
|
+
__privateSet(this, _publisher, new PublishInstruments(publishInstrumentsOptions));
|
|
4743
|
+
this.StartPublish();
|
|
4744
|
+
}
|
|
4745
|
+
}
|
|
4746
|
+
get options() {
|
|
4747
|
+
return super.options;
|
|
4748
|
+
}
|
|
4749
|
+
async StartPublish() {
|
|
4750
|
+
if (__privateGet(this, _worker)) {
|
|
4751
|
+
return true;
|
|
4752
|
+
} else {
|
|
4753
|
+
return __privateGet(this, _publisher).StartPublish();
|
|
4754
|
+
}
|
|
4755
|
+
}
|
|
4756
|
+
async EndPublish() {
|
|
4757
|
+
if (__privateGet(this, _worker)) {
|
|
4758
|
+
return true;
|
|
4759
|
+
} else {
|
|
4760
|
+
return __privateGet(this, _publisher).EndPublish();
|
|
4761
|
+
}
|
|
4762
|
+
}
|
|
4763
|
+
async Publish() {
|
|
4764
|
+
if (__privateGet(this, _worker)) {
|
|
4765
|
+
return true;
|
|
4766
|
+
} else {
|
|
4767
|
+
return __privateGet(this, _publisher).Publish();
|
|
4768
|
+
}
|
|
4769
|
+
}
|
|
4770
|
+
GetPayloadData() {
|
|
4771
|
+
const context = this.options.processContext;
|
|
4772
|
+
const instruments = __privateGet(this, _instruments);
|
|
4773
|
+
const payloadInstruments = {};
|
|
4774
|
+
for (const [key, value] of Object.entries(instruments)) {
|
|
4775
|
+
if (value instanceof InstrumentLog) {
|
|
4776
|
+
payloadInstruments[key] = { ...value.WithUseLatestMessages(true) };
|
|
4777
|
+
} else {
|
|
4778
|
+
payloadInstruments[key] = { ...value };
|
|
4779
|
+
}
|
|
4780
|
+
}
|
|
4781
|
+
return {
|
|
4782
|
+
context,
|
|
4783
|
+
instruments: payloadInstruments
|
|
4784
|
+
};
|
|
4785
|
+
}
|
|
4786
|
+
SetupInstrumentation() {
|
|
4787
|
+
if (!this.options.instrumentDefinitions) {
|
|
4788
|
+
this.options.logger.debug(chalk$1.yellow(`SetupInstrumentation:${this.options.processContext.nid}: No instrument(s) defined within supplied options.`));
|
|
4789
|
+
return;
|
|
4790
|
+
}
|
|
4791
|
+
if (!this.options.processContext) {
|
|
4792
|
+
this.options.logger.debug(chalk$1.yellow(`SetupInstrumentation: No context defined within supplied options.`));
|
|
4793
|
+
return;
|
|
4794
|
+
}
|
|
4795
|
+
__privateMethod(this, _PublishInstrumentController_instances, CreateInstruments_fn).call(this, this.options.instrumentDefinitions);
|
|
4796
|
+
}
|
|
4797
|
+
/**
|
|
4798
|
+
* Check if an instrument exists within the managed instrument collection
|
|
4799
|
+
* @param instrumentName
|
|
4800
|
+
* @returns
|
|
4801
|
+
*/
|
|
4802
|
+
InstrumentExists(instrumentName) {
|
|
4803
|
+
if (__privateGet(this, _instruments)[instrumentName]) {
|
|
4804
|
+
return true;
|
|
4805
|
+
}
|
|
4806
|
+
return false;
|
|
4807
|
+
}
|
|
4808
|
+
/**
|
|
4809
|
+
* Update instrument telemetry.
|
|
4810
|
+
* @param instrumentName
|
|
4811
|
+
* @param telemetry
|
|
4812
|
+
*/
|
|
4813
|
+
UpdateInstrument(instrumentName, telemetry) {
|
|
4814
|
+
if (__privateGet(this, _instruments)[instrumentName]) {
|
|
4815
|
+
__privateMethod(this, _PublishInstrumentController_instances, ProcessTelemetryCommand_fn).call(this, instrumentName, telemetry);
|
|
4816
|
+
} else {
|
|
4817
|
+
this.options.logger.debug(chalk$1.red(`UpdateInstrument:${this.options.processContext.nid}: Attempted to UpdateInstrument before initialised.`));
|
|
4818
|
+
}
|
|
4819
|
+
}
|
|
4820
|
+
/**
|
|
4821
|
+
* Add additional instrument publishers. Usually invoked when adding workers to the app and/or async runners within a worker.
|
|
4822
|
+
* @param processContext
|
|
4823
|
+
* @returns Returns the newly created PublishInstrumentController
|
|
4824
|
+
*/
|
|
4825
|
+
AddPublishInstrumentController(processContext) {
|
|
4826
|
+
const options = { ...this.options };
|
|
4827
|
+
options.processContext = processContext;
|
|
4828
|
+
return new _PublishInstrumentController(options);
|
|
4829
|
+
}
|
|
4830
|
+
};
|
|
4831
|
+
_instruments = new WeakMap();
|
|
4832
|
+
_worker = new WeakMap();
|
|
4833
|
+
_publisher = new WeakMap();
|
|
4834
|
+
_PublishInstrumentController_instances = new WeakSet();
|
|
4835
|
+
GetInstrument_fn = function(instrumentName) {
|
|
4836
|
+
return __privateGet(this, _instruments)[instrumentName];
|
|
4837
|
+
};
|
|
4838
|
+
ProcessTelemetryCommand_fn = function(instrumentName, telemetry) {
|
|
4839
|
+
const instrument = __privateMethod(this, _PublishInstrumentController_instances, GetInstrument_fn).call(this, instrumentName);
|
|
4840
|
+
if (instrument) {
|
|
4841
|
+
instrument.ProcessTelemetry(telemetry);
|
|
4842
|
+
}
|
|
4843
|
+
};
|
|
4844
|
+
// Instrument factory
|
|
4845
|
+
CreateInstrument_fn = function(instrumentType, options) {
|
|
4846
|
+
let instrument;
|
|
4847
|
+
switch (instrumentType) {
|
|
4848
|
+
case GaugeTypes.INSTRUMENT_GAUGE:
|
|
4849
|
+
instrument = new InstrumentGauge(options);
|
|
4850
|
+
break;
|
|
4851
|
+
case GaugeTypes.INSTRUMENT_HISTOGRAM:
|
|
4852
|
+
instrument = new InstrumentHistogram(options);
|
|
4853
|
+
break;
|
|
4854
|
+
case GaugeTypes.INSTRUMENT_LOG:
|
|
4855
|
+
instrument = new InstrumentLog(options);
|
|
4856
|
+
break;
|
|
4857
|
+
case GaugeTypes.INSTRUMENT_OBJECT:
|
|
4858
|
+
instrument = new InstrumentObject(options);
|
|
4859
|
+
break;
|
|
4860
|
+
case GaugeTypes.INSTRUMENT_TIMER:
|
|
4861
|
+
instrument = new InstrumentTimerGauge(options);
|
|
4862
|
+
break;
|
|
4863
|
+
case GaugeTypes.INSTRUMENT_VELOCITY:
|
|
4864
|
+
instrument = new InstrumentVelocity(options);
|
|
4865
|
+
break;
|
|
4866
|
+
default:
|
|
4867
|
+
throw new Error(`Gauge type: [${instrumentType} not known.]`);
|
|
4868
|
+
}
|
|
4869
|
+
return instrument;
|
|
4870
|
+
};
|
|
4871
|
+
CreateInstruments_fn = function(payload) {
|
|
4872
|
+
payload.forEach((instrumentDefinition) => {
|
|
4873
|
+
const g = instrumentDefinition[0];
|
|
4874
|
+
const gt = instrumentDefinition[1];
|
|
4875
|
+
const instrumentBaseOptions = instrumentDefinition[2];
|
|
4876
|
+
const instrument = __privateMethod(this, _PublishInstrumentController_instances, CreateInstrument_fn).call(this, gt, instrumentBaseOptions);
|
|
4877
|
+
__privateGet(this, _instruments)[g] = instrument;
|
|
4878
|
+
});
|
|
4879
|
+
};
|
|
4880
|
+
let PublishInstrumentController = _PublishInstrumentController;
|
|
4881
|
+
const STSInstrumentControllerPluginKey = Symbol("instrumentController");
|
|
4882
|
+
const GetSTSInstrumentControllerPluginKey = () => STSInstrumentControllerPluginKey;
|
|
4883
|
+
const CompareSTSInstrumentControllerPluginKey = (val) => val === STSInstrumentControllerPluginKey;
|
|
4884
|
+
const useSTSInstrumentControllerPlugin = () => vue.inject(STSInstrumentControllerPluginKey);
|
|
4885
|
+
const GetSTSInstrumentController = (app) => {
|
|
4886
|
+
return app.config.globalProperties.$sts[STSInstrumentControllerPluginKey];
|
|
4887
|
+
};
|
|
4888
|
+
const STSInstrumentControllerPlugin = {
|
|
4889
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4890
|
+
install: (app, options) => {
|
|
4891
|
+
options.logger.debug(chalk$1.yellow(`STSInstrumentControllerPlugin:install:Start`));
|
|
4892
|
+
const aic = new PublishInstrumentController(options);
|
|
4893
|
+
if (!app.config.globalProperties.$sts) {
|
|
4894
|
+
options.logger.debug(chalk$1.cyan(`STSInstrumentControllerPlugin:install: [app.config.globalProperties.$sts] does not exist.`));
|
|
4895
|
+
app.config.globalProperties.$sts = {};
|
|
4896
|
+
options.logger.debug(chalk$1.cyan(`STSInstrumentControllerPlugin:install: created empty [app.config.globalProperties.$sts].`));
|
|
4897
|
+
} else {
|
|
4898
|
+
options.logger.debug(chalk$1.cyan(`STSInstrumentControllerPlugin:install: [app.config.globalProperties.$sts] already exists.`));
|
|
4899
|
+
}
|
|
4900
|
+
app.config.globalProperties.$sts.aic = aic;
|
|
4901
|
+
app.config.globalProperties.$sts[STSInstrumentControllerPluginKey] = aic;
|
|
4902
|
+
options.logger.debug(chalk$1.cyan(`STSInstrumentControllerPlugin:install: AgentInstrumentController installed into [app.config.globalProperties.$sts] using: [${String(STSInstrumentControllerPluginKey)}].`));
|
|
4903
|
+
app.provide(STSInstrumentControllerPluginKey, aic);
|
|
4904
|
+
options.logger.debug(chalk$1.cyan(`STSInstrumentControllerPlugin:install: AgentInstrumentController installed into 'provide' using: [${String(STSInstrumentControllerPluginKey)}].`));
|
|
4905
|
+
options.logger.debug(chalk$1.green(`STSInstrumentControllerPlugin:install:End`));
|
|
4906
|
+
}
|
|
4907
|
+
};
|
|
4962
4908
|
var SubscriptionTopic = /* @__PURE__ */ ((SubscriptionTopic2) => {
|
|
4963
4909
|
SubscriptionTopic2["AllServicesCombined"] = "AllServicesCombined";
|
|
4964
4910
|
SubscriptionTopic2["Services"] = "Services";
|
|
@@ -5783,13 +5729,6 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
5783
5729
|
var rnds = options.random || (options.rng || rng)();
|
|
5784
5730
|
rnds[6] = rnds[6] & 15 | 64;
|
|
5785
5731
|
rnds[8] = rnds[8] & 63 | 128;
|
|
5786
|
-
if (buf) {
|
|
5787
|
-
offset = offset || 0;
|
|
5788
|
-
for (var i2 = 0; i2 < 16; ++i2) {
|
|
5789
|
-
buf[offset + i2] = rnds[i2];
|
|
5790
|
-
}
|
|
5791
|
-
return buf;
|
|
5792
|
-
}
|
|
5793
5732
|
return unsafeStringify(rnds);
|
|
5794
5733
|
}
|
|
5795
5734
|
var messageStatus = /* @__PURE__ */ ((messageStatus2) => {
|