improve: logging
This commit is contained in:
parent
7ad4255fa7
commit
189bb294cb
@ -236,18 +236,18 @@ export async function adjustSnapshotTime(
|
|||||||
if (delayedDate.getTime() < now.getTime()) {
|
if (delayedDate.getTime() < now.getTime()) {
|
||||||
const elapsed = performance.now() - t;
|
const elapsed = performance.now() - t;
|
||||||
timePerIteration = elapsed / (i+1);
|
timePerIteration = elapsed / (i+1);
|
||||||
logger.log(`${timePerIteration.toFixed(3)}ms * ${i+1}iterations`, "perf", "fn:adjustSnapshotTime");
|
logger.log(`${timePerIteration.toFixed(3)}ms * ${i+1} iterations`, "perf", "fn:adjustSnapshotTime");
|
||||||
return now;
|
return now;
|
||||||
}
|
}
|
||||||
const elapsed = performance.now() - t;
|
const elapsed = performance.now() - t;
|
||||||
timePerIteration = elapsed / (i+1);
|
timePerIteration = elapsed / (i+1);
|
||||||
logger.log(`${timePerIteration.toFixed(3)}ms * ${i+1}iterations`, "perf", "fn:adjustSnapshotTime");
|
logger.log(`${timePerIteration.toFixed(3)}ms * ${i+1} iterations`, "perf", "fn:adjustSnapshotTime");
|
||||||
return delayedDate;
|
return delayedDate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const elapsed = performance.now() - t;
|
const elapsed = performance.now() - t;
|
||||||
timePerIteration = elapsed / WINDOW_SIZE;
|
timePerIteration = elapsed / WINDOW_SIZE;
|
||||||
logger.log(`${timePerIteration.toFixed(3)}ms * ${WINDOW_SIZE}iterations`, "perf", "fn:adjustSnapshotTime");
|
logger.log(`${timePerIteration.toFixed(3)}ms * ${WINDOW_SIZE} iterations`, "perf", "fn:adjustSnapshotTime");
|
||||||
return expectedStartTime;
|
return expectedStartTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ export const regularSnapshotsWorker = async (_job: Job) => {
|
|||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
const lastSnapshotedAt = latestSnapshot?.time ?? now;
|
const lastSnapshotedAt = latestSnapshot?.time ?? now;
|
||||||
const interval = await getRegularSnapshotInterval(client, aid);
|
const interval = await getRegularSnapshotInterval(client, aid);
|
||||||
logger.log(`Schedule regular snapshot for aid ${aid} in ${interval} hours.`, "mq");
|
logger.log(`Scheduled regular snapshot for aid ${aid} in ${interval} hours.`, "mq");
|
||||||
const targetTime = truncate(lastSnapshotedAt + interval * HOUR, now + 1, now + 100000 * WEEK);
|
const targetTime = truncate(lastSnapshotedAt + interval * HOUR, now + 1, now + 100000 * WEEK);
|
||||||
await scheduleSnapshot(client, aid, "normal", targetTime);
|
await scheduleSnapshot(client, aid, "normal", targetTime);
|
||||||
if (now - startedAt > 25 * MINUTE) {
|
if (now - startedAt > 25 * MINUTE) {
|
||||||
@ -251,7 +251,7 @@ export const takeBulkSnapshotForVideosWorker = async (job: Job) => {
|
|||||||
}
|
}
|
||||||
for (const aid of aidsToFetch) {
|
for (const aid of aidsToFetch) {
|
||||||
const interval = await getRegularSnapshotInterval(client, aid);
|
const interval = await getRegularSnapshotInterval(client, aid);
|
||||||
logger.log(`Schedule regular snapshot for aid ${aid} in ${interval} hours.`, "mq");
|
logger.log(`Scheduled regular snapshot for aid ${aid} in ${interval} hours.`, "mq");
|
||||||
await scheduleSnapshot(client, aid, "normal", Date.now() + interval * HOUR);
|
await scheduleSnapshot(client, aid, "normal", Date.now() + interval * HOUR);
|
||||||
}
|
}
|
||||||
return `DONE`;
|
return `DONE`;
|
||||||
@ -288,7 +288,7 @@ export const takeSnapshotForVideoWorker = async (job: Job) => {
|
|||||||
await setSnapshotStatus(client, id, "completed");
|
await setSnapshotStatus(client, id, "completed");
|
||||||
if (type === "normal") {
|
if (type === "normal") {
|
||||||
const interval = await getRegularSnapshotInterval(client, aid);
|
const interval = await getRegularSnapshotInterval(client, aid);
|
||||||
logger.log(`Schedule regular snapshot for aid ${aid} in ${interval} hours.`, "mq");
|
logger.log(`Scheduled regular snapshot for aid ${aid} in ${interval} hours.`, "mq");
|
||||||
await scheduleSnapshot(client, aid, type, Date.now() + interval * HOUR);
|
await scheduleSnapshot(client, aid, type, Date.now() + interval * HOUR);
|
||||||
return `DONE`;
|
return `DONE`;
|
||||||
} else if (type === "new") {
|
} else if (type === "new") {
|
||||||
|
Loading…
Reference in New Issue
Block a user