Skip to content

Commit 19e9b9d

Browse files
committed
perf(controllers): log final backup chunks received
1 parent b321e11 commit 19e9b9d

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/v3/controllers/users_controller.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,11 @@ export const saveUserChunkedBackup = async (req: Request, res: Response) => {
12521252
// save chunk
12531253
findBackup.chunks[chunkIndex] = chunkData;
12541254
findBackup.received++;
1255+
logger(
1256+
LogLevel.Info,
1257+
`congregation backup chunk ${chunkIndex + 1} out of ${totalChunks} received, by ${user.id}, for ${cong.id}`,
1258+
{ congregationId: cong.id, userId: user.id }
1259+
);
12551260

12561261
if (findBackup.received === findBackup.totalChunks) {
12571262
const congBackupStr = findBackup.chunks.join('');
@@ -1286,6 +1291,6 @@ export const saveUserChunkedBackup = async (req: Request, res: Response) => {
12861291
}
12871292

12881293
res.locals.type = 'info';
1289-
res.locals.message = `congregation backup chunk ${chunkIndex + 1} out of ${totalChunks} received`;
1294+
res.locals.message = `congregation backup chunk processed`;
12901295
res.status(200).json({ message: 'BACKUP_CHUNK_RECEIVED' });
12911296
};

src/v3/middleware/update_tracker.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,6 @@ export const updateTracker = () => {
5050

5151
const memory = process.memoryUsage();
5252

53-
const memory_usage = {
54-
rssMB: +(memory.rss / 1024 / 1024).toFixed(2),
55-
heapTotalMB: +(memory.heapTotal / 1024 / 1024).toFixed(2),
56-
heapUsedMB: +(memory.heapUsed / 1024 / 1024).toFixed(2),
57-
externalMB: +(memory.external / 1024 / 1024).toFixed(2),
58-
arrayBuffersMB: +(memory.arrayBuffers / 1024 / 1024).toFixed(2),
59-
};
60-
6153
const context = {
6254
method: req.method,
6355
status: res.statusCode,
@@ -69,7 +61,10 @@ export const updateTracker = () => {
6961
congregationId: user?.profile.congregation?.id,
7062
duration: ms,
7163
size: responseSize,
72-
memory_usage,
64+
memory_rss: memory.rss,
65+
memory_heap_total: memory.heapTotal,
66+
memory_heap_used: memory.heapUsed,
67+
memory_array_buffers: memory.arrayBuffers,
7368
};
7469

7570
let failedLoginAttempt = 0;
@@ -101,7 +96,7 @@ export const updateTracker = () => {
10196
}
10297

10398
res.status(400);
104-
logger(LogLevel.Warn, message, context);
99+
logger(LogLevel.Warn, 'request aborted and cannot be completed', context);
105100
}
106101
});
107102

0 commit comments

Comments
 (0)