Skip to content

Commit

Permalink
[feature] Add 'coauth.saveAfterEditingSessionClosed' metric
Browse files Browse the repository at this point in the history
  • Loading branch information
konovalovsergey committed Oct 8, 2024
1 parent bd0a7d2 commit 74a917a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion DocService/sources/canvasservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 74a917a

Please sign in to comment.