dowwntime 1.3.3 → 1.3.5
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 +13 -10
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +13 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -14886,7 +14886,7 @@ const debug$1 = debug("dowwntime");
|
|
|
14886
14886
|
*/
|
|
14887
14887
|
const measureRequest = async (url$2, options) => {
|
|
14888
14888
|
const startAt = Date.now();
|
|
14889
|
-
return await new Promise((resolve$1) => {
|
|
14889
|
+
return await new Promise((resolve$1, reject) => {
|
|
14890
14890
|
let tlsHandshakeAt;
|
|
14891
14891
|
let firstByteAt;
|
|
14892
14892
|
const req = ((typeof url$2 === "string" ? new URL(url$2) : url$2).protocol === "https:" ? https : http).request(url$2, options, (res) => {
|
|
@@ -14901,6 +14901,9 @@ const measureRequest = async (url$2, options) => {
|
|
|
14901
14901
|
});
|
|
14902
14902
|
});
|
|
14903
14903
|
});
|
|
14904
|
+
req.on("error", (err) => {
|
|
14905
|
+
reject(err);
|
|
14906
|
+
});
|
|
14904
14907
|
req.on("socket", (socket) => {
|
|
14905
14908
|
socket.on("secureConnect", () => {
|
|
14906
14909
|
tlsHandshakeAt = Date.now();
|
|
@@ -28407,20 +28410,20 @@ const run = async (options) => {
|
|
|
28407
28410
|
}
|
|
28408
28411
|
const reports = await Promise.all([...fetchConfigurations.keys()].map(async (path$4) => {
|
|
28409
28412
|
const history = await measurements.getHistory(path$4);
|
|
28410
|
-
const startOfPast60m = (0, import_dayjs_min.default)().subtract(60, "minute").startOf("minute").
|
|
28411
|
-
const startOfPast24h = (0, import_dayjs_min.default)().subtract(24, "hours").startOf("hour").
|
|
28412
|
-
const startOfPast7d = (0, import_dayjs_min.default)().subtract(7, "day").startOf("day").
|
|
28413
|
-
const startOfPast30d = (0, import_dayjs_min.default)().subtract(30, "day").startOf("day").
|
|
28414
|
-
const
|
|
28413
|
+
const startOfPast60m = (0, import_dayjs_min.default)().subtract(60, "minute").startOf("minute").valueOf();
|
|
28414
|
+
const startOfPast24h = (0, import_dayjs_min.default)().subtract(24, "hours").startOf("hour").valueOf();
|
|
28415
|
+
const startOfPast7d = (0, import_dayjs_min.default)().subtract(7, "day").startOf("day").valueOf();
|
|
28416
|
+
const startOfPast30d = (0, import_dayjs_min.default)().subtract(30, "day").startOf("day").valueOf();
|
|
28417
|
+
const getAverageDuration = (since) => {
|
|
28415
28418
|
const filtered = history.filter((item) => item.timestamp >= since);
|
|
28416
28419
|
if (filtered.length === 0) return null;
|
|
28417
28420
|
const total = filtered.reduce((acc, curr) => acc + curr.durationMs, 0);
|
|
28418
28421
|
return Math.round(total / filtered.length);
|
|
28419
28422
|
};
|
|
28420
|
-
const avgDuration60m =
|
|
28421
|
-
const avgDuration24h =
|
|
28422
|
-
const avgDuration7d =
|
|
28423
|
-
const avgDuration30d =
|
|
28423
|
+
const avgDuration60m = getAverageDuration(startOfPast60m);
|
|
28424
|
+
const avgDuration24h = getAverageDuration(startOfPast24h);
|
|
28425
|
+
const avgDuration7d = getAverageDuration(startOfPast7d);
|
|
28426
|
+
const avgDuration30d = getAverageDuration(startOfPast30d);
|
|
28424
28427
|
const getRelativeDowntime = (since) => {
|
|
28425
28428
|
const filtered = history.filter((item) => item.timestamp >= since);
|
|
28426
28429
|
if (filtered.length === 0) return null;
|