[docstore] add metrics for writes to docs collection (#31741)

* [docstore] add metrics for writes to docs collection

Co-authored-by: Brian Gough <brian.gough@overleaf.com>

* [docstore] fix import

* [docstore] use counter metric

* [docstore] add metric on lines delta

Co-authored-by: Brian Gough <brian.gough@overleaf.com>

---------

Co-authored-by: Brian Gough <brian.gough@overleaf.com>
GitOrigin-RevId: 4662c5862315c800cb7b4d57bef60e08fbe7ba59
This commit is contained in:
Jakob Ackermann
2026-02-24 09:05:35 +00:00
committed by Copybot
co-authored by Brian Gough
parent fe65bc2cc1
commit d7514feafe
4 changed files with 30 additions and 3 deletions
+14
View File
@@ -6,6 +6,7 @@ import DocArchive from './DocArchiveManager.js'
import RangeManager from './RangeManager.js'
import Settings from '@overleaf/settings'
import { setTimeout } from 'node:timers/promises'
import Metrics from '@overleaf/metrics'
/**
* @import { Document } from 'mongodb'
@@ -255,6 +256,19 @@ const DocManager = {
})
}
updateLines = !_.isEqual(doc.lines, lines)
if (doc.lines.length === lines.length) {
Metrics.inc('mongo_docs_update_delta', 1, {
status: 'same-line-length',
})
} else if (doc.lines.length > lines.length) {
Metrics.inc('mongo_docs_update_delta', 1, {
status: 'smaller-line-length',
})
} else if (doc.lines.length < lines.length) {
Metrics.inc('mongo_docs_update_delta', 1, {
status: 'larger-line-length',
})
}
updateVersion = doc.version !== version
updateRanges = RangeManager.shouldUpdateRanges(doc.ranges, ranges)
}