@lokalise/healthcheck-utils 1.2.0 → 1.2.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.
|
@@ -10,7 +10,7 @@ class HealthcheckResultsStore {
|
|
|
10
10
|
constructor(params) {
|
|
11
11
|
this.stalenessThresholdInMsecs =
|
|
12
12
|
params.stalenessThresholdInMsecs ?? DEFAULT_STALENESS_THRESHOLD_IN_MSECS;
|
|
13
|
-
this.store = new toad_cache_1.FifoMap(params.
|
|
13
|
+
this.store = new toad_cache_1.FifoMap(params.maxHealthcheckNumber, params.healthCheckResultTtlInMsecs ?? DEFAULT_HEALTHCHECK_TTL_IN_MSECS);
|
|
14
14
|
}
|
|
15
15
|
set(healthcheck, result) {
|
|
16
16
|
this.store.set(healthcheck, result);
|
package/dist/healthchecks.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AbstractHealthcheck = void 0;
|
|
4
4
|
const prom_client_1 = require("prom-client");
|
|
5
|
-
|
|
5
|
+
const metricsRegistered = new Map();
|
|
6
6
|
class AbstractHealthcheck {
|
|
7
7
|
areMetricsEnabled;
|
|
8
8
|
store;
|
|
@@ -14,11 +14,11 @@ class AbstractHealthcheck {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
instantiateMetrics() {
|
|
17
|
-
|
|
17
|
+
const id = this.getId();
|
|
18
|
+
if (!this.areMetricsEnabled || metricsRegistered.get(id)) {
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
20
21
|
const store = this.store;
|
|
21
|
-
const id = this.getId();
|
|
22
22
|
new prom_client_1.Gauge({
|
|
23
23
|
name: `${id}_availability`,
|
|
24
24
|
help: `Whether ${id} was available at the time`,
|
|
@@ -35,7 +35,7 @@ class AbstractHealthcheck {
|
|
|
35
35
|
this.set(checkLength ?? 0);
|
|
36
36
|
},
|
|
37
37
|
});
|
|
38
|
-
metricsRegistered
|
|
38
|
+
metricsRegistered.set(id, true);
|
|
39
39
|
}
|
|
40
40
|
async execute() {
|
|
41
41
|
const result = await this.check();
|