dowwntime 1.3.0 → 1.3.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/dist/cli.mjs +24 -22
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +24 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -28346,29 +28346,26 @@ const run = async (options) => {
|
|
|
28346
28346
|
const measure = async (path$4) => {
|
|
28347
28347
|
const url$2 = fetchConfigurations.get(path$4);
|
|
28348
28348
|
if (!url$2) return;
|
|
28349
|
-
let status = "down";
|
|
28350
|
-
let durationMs;
|
|
28351
28349
|
const start = Date.now();
|
|
28352
28350
|
try {
|
|
28353
28351
|
const metrics = await measureRequest(url$2, {
|
|
28354
28352
|
method: "GET",
|
|
28355
28353
|
timeout: options.timeoutMs ?? 5e3
|
|
28356
28354
|
});
|
|
28357
|
-
|
|
28358
|
-
|
|
28359
|
-
|
|
28355
|
+
debug$1(`Measured ${path$4}:`, metrics);
|
|
28356
|
+
return {
|
|
28357
|
+
...metrics,
|
|
28358
|
+
url: url$2.toString(),
|
|
28359
|
+
timestamp: start
|
|
28360
|
+
};
|
|
28360
28361
|
} catch (_error) {
|
|
28361
|
-
|
|
28362
|
-
|
|
28362
|
+
return {
|
|
28363
|
+
statusCode: 0,
|
|
28364
|
+
durationMs: Date.now() - start,
|
|
28365
|
+
url: url$2.toString(),
|
|
28366
|
+
timestamp: start
|
|
28367
|
+
};
|
|
28363
28368
|
}
|
|
28364
|
-
const measurement = {
|
|
28365
|
-
status,
|
|
28366
|
-
durationMs,
|
|
28367
|
-
timestamp: start,
|
|
28368
|
-
url: url$2.toString()
|
|
28369
|
-
};
|
|
28370
|
-
debug$1(`Measured ${path$4}:`, measurement);
|
|
28371
|
-
return measurement;
|
|
28372
28369
|
};
|
|
28373
28370
|
const throttledMeasure = pThrottle({
|
|
28374
28371
|
limit: options.concurrency ?? 5,
|
|
@@ -28382,13 +28379,18 @@ const run = async (options) => {
|
|
|
28382
28379
|
const iqr = q3 - q1;
|
|
28383
28380
|
const lowerBound = q1 - 1.5 * iqr;
|
|
28384
28381
|
const upperBound = q3 + 1.5 * iqr;
|
|
28385
|
-
const
|
|
28386
|
-
|
|
28387
|
-
|
|
28388
|
-
|
|
28389
|
-
|
|
28390
|
-
|
|
28391
|
-
|
|
28382
|
+
const filteredResults = results.filter((r) => r && r.durationMs >= lowerBound && r.durationMs <= upperBound);
|
|
28383
|
+
const durationMs = Math.round(filteredResults.reduce((acc, curr) => acc + (curr?.durationMs ?? 0), 0) / filteredResults.length);
|
|
28384
|
+
let status = "down";
|
|
28385
|
+
const statusCode = Math.max(...filteredResults.map((r) => r?.statusCode ?? 0));
|
|
28386
|
+
if (options.getStatus) status = options.getStatus(statusCode, path$4, durationMs);
|
|
28387
|
+
else status = statusCode >= 200 ? "up" : "down";
|
|
28388
|
+
const measurement = {
|
|
28389
|
+
status,
|
|
28390
|
+
durationMs,
|
|
28391
|
+
timestamp: Date.now(),
|
|
28392
|
+
url: fetchConfigurations.get(path$4)?.toString() ?? ""
|
|
28393
|
+
};
|
|
28392
28394
|
debug$1(`Measured ${path$4} (avg):`, measurement);
|
|
28393
28395
|
if (!measurement) return;
|
|
28394
28396
|
await measurements.add(path$4, measurement);
|