@mablhq/mabl-cli 2.12.23 → 2.14.1
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/api/featureSet.js +1 -1
- package/execution/index.js +5 -5
- package/package.json +2 -2
- package/proxy/index.js +1 -1
- package/util/InternalMetricsTrackingSingleton.js +36 -0
- package/util/logUtils.js +12 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InternalMetricsTrackingSingleton = void 0;
|
|
4
|
+
const logUtils_1 = require("./logUtils");
|
|
5
|
+
class InternalMetricsTrackingSingleton {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.metadata = {};
|
|
8
|
+
}
|
|
9
|
+
static getInstance() {
|
|
10
|
+
if (!InternalMetricsTrackingSingleton.instance) {
|
|
11
|
+
InternalMetricsTrackingSingleton.instance =
|
|
12
|
+
new InternalMetricsTrackingSingleton();
|
|
13
|
+
}
|
|
14
|
+
return InternalMetricsTrackingSingleton.instance;
|
|
15
|
+
}
|
|
16
|
+
addMetric(name, value) {
|
|
17
|
+
this.metadata[name] = value;
|
|
18
|
+
}
|
|
19
|
+
addMetrics(metrics) {
|
|
20
|
+
this.metadata = { ...this.metadata, ...metrics };
|
|
21
|
+
}
|
|
22
|
+
testType(testType) {
|
|
23
|
+
this.metadata.testType = testType;
|
|
24
|
+
}
|
|
25
|
+
testStatus(testStatus) {
|
|
26
|
+
this.metadata.testStatus = testStatus;
|
|
27
|
+
}
|
|
28
|
+
reportMetrics() {
|
|
29
|
+
if (Object.keys(this.metadata).length === 0) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
(0, logUtils_1.logInternal)('Internal metrics:', this.metadata);
|
|
33
|
+
this.metadata = {};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.InternalMetricsTrackingSingleton = InternalMetricsTrackingSingleton;
|
package/util/logUtils.js
CHANGED
|
@@ -3,12 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getPromiseSettledValues = exports.logPromiseSettledRejections = exports.logErrorVerbose = exports.formatTimestamp = exports.valueToString = exports.logWebUIAndCliOutput = exports.logWebUI = exports.findResultSeverityToLogLevel = exports.logCliOutput = exports.logInternal = void 0;
|
|
6
|
+
exports.promiseRejectionMiddlewareMetric = exports.getPromiseSettledValues = exports.logPromiseSettledRejections = exports.logErrorVerbose = exports.formatTimestamp = exports.valueToString = exports.logWebUIAndCliOutput = exports.logWebUI = exports.findResultSeverityToLogLevel = exports.logCliOutput = exports.logInternal = void 0;
|
|
7
7
|
const mablscriptFind_1 = require("../mablscriptFind");
|
|
8
8
|
const loggingProvider_1 = require("../providers/logging/loggingProvider");
|
|
9
9
|
const moment_1 = __importDefault(require("moment"));
|
|
10
10
|
const constants_1 = require("../commands/constants");
|
|
11
11
|
const pureUtil_1 = require("./pureUtil");
|
|
12
|
+
const InternalMetricsTrackingSingleton_1 = require("./InternalMetricsTrackingSingleton");
|
|
12
13
|
function logInternal(logLine, ...meta) {
|
|
13
14
|
loggingProvider_1.logger.debug(logLine, meta);
|
|
14
15
|
}
|
|
@@ -105,3 +106,13 @@ function getPromiseSettledValues(promises, reThrow = false) {
|
|
|
105
106
|
return promises.filter(pureUtil_1.isFulfilledPromise).map((promise) => promise.value);
|
|
106
107
|
}
|
|
107
108
|
exports.getPromiseSettledValues = getPromiseSettledValues;
|
|
109
|
+
async function promiseRejectionMiddlewareMetric(promise, metricName, metricValue) {
|
|
110
|
+
try {
|
|
111
|
+
return await promise;
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
InternalMetricsTrackingSingleton_1.InternalMetricsTrackingSingleton.getInstance().addMetric(metricName, metricValue);
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
exports.promiseRejectionMiddlewareMetric = promiseRejectionMiddlewareMetric;
|