[feature] Add 'coauth.saveAfterEditingSessionClosed' metric

This commit is contained in:
Sergey Konovalov
2024-10-08 10:17:01 +03:00
parent bd0a7d2925
commit 74a917a788

View File

@ -971,7 +971,7 @@ const commandSfcCallback = co.wrap(function*(ctx, cmd, isSfcm, isEncrypted) {
let forceSaveUserId = forceSave ? forceSave.getAuthorUserId() : undefined;
let forceSaveUserIndex = forceSave ? forceSave.getAuthorUserIndex() : undefined;
let callbackUserIndex = (forceSaveUserIndex || 0 === forceSaveUserIndex) ? forceSaveUserIndex : userLastChangeIndex;
let uri, baseUrl, wopiParams;
let uri, baseUrl, wopiParams, lastOpenDate;
let selectRes = yield taskResult.select(ctx, docId);
let row = selectRes.length > 0 ? selectRes[0] : null;
if (row) {
@ -982,6 +982,7 @@ const commandSfcCallback = co.wrap(function*(ctx, cmd, isSfcm, isEncrypted) {
if (row.baseurl) {
baseUrl = row.baseurl;
}
lastOpenDate = row.last_open_date;
}
var isSfcmSuccess = false;
let storeForgotten = false;
@ -1190,6 +1191,14 @@ const commandSfcCallback = co.wrap(function*(ctx, cmd, isSfcm, isEncrypted) {
//remove forgotten file in cache
yield cleanupCache(ctx, docId);
}
if (lastOpenDate) {
//todo error case
let time = new Date() - lastOpenDate;
ctx.logger.debug('commandSfcCallback saveAfterEditingSessionClosed=%d', time);
if (clientStatsD) {
clientStatsD.timing('coauth.saveAfterEditingSessionClosed', time);
}
}
} else {
storeForgotten = true;
}