mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-25 06:12:52 +00:00
Merge pull request #9633 from overleaf/bg-external-update-metric
add a metric for external updates in docupdater GitOrigin-RevId: db407f742bea692e3617eec08db4756e3b8adbd9
This commit is contained in:
parent
c41c14c697
commit
348035f6ff
2 changed files with 29 additions and 0 deletions
|
@ -222,6 +222,13 @@ module.exports = DocumentManager = {
|
|||
user_id: userId,
|
||||
},
|
||||
}
|
||||
// Keep track of external updates, whether they are for live documents
|
||||
// (flush) or unloaded documents (evict), and whether the update is a no-op.
|
||||
Metrics.inc('external-update', 1, {
|
||||
status: op.length > 0 ? 'diff' : 'noop',
|
||||
method: alreadyLoaded ? 'flush' : 'evict',
|
||||
path: source,
|
||||
})
|
||||
UpdateManager.applyUpdate(projectId, docId, update, error => {
|
||||
if (error) {
|
||||
return callback(error)
|
||||
|
|
|
@ -9,6 +9,7 @@ describe('DocumentManager', function () {
|
|||
tk.freeze(new Date())
|
||||
this.Metrics = {
|
||||
Timer: class Timer {},
|
||||
inc: sinon.stub(),
|
||||
}
|
||||
this.Metrics.Timer.prototype.done = sinon.stub()
|
||||
|
||||
|
@ -42,6 +43,7 @@ describe('DocumentManager', function () {
|
|||
this.unflushedTime = Date.now()
|
||||
this.lastUpdatedAt = Date.now()
|
||||
this.lastUpdatedBy = 'last-author-id'
|
||||
this.source = 'external-source'
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
|
@ -517,6 +519,16 @@ describe('DocumentManager', function () {
|
|||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should increment the external update metric', function () {
|
||||
this.Metrics.inc
|
||||
.calledWith('external-update', 1, {
|
||||
status: 'diff',
|
||||
method: 'flush',
|
||||
path: this.source,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should flush the doc to Mongo', function () {
|
||||
this.DocumentManager.flushDocIfLoaded
|
||||
.calledWith(this.project_id, this.doc_id)
|
||||
|
@ -568,6 +580,16 @@ describe('DocumentManager', function () {
|
|||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should increment the external update metric', function () {
|
||||
this.Metrics.inc
|
||||
.calledWith('external-update', 1, {
|
||||
status: 'diff',
|
||||
method: 'evict',
|
||||
path: this.source,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should not flush the project history', function () {
|
||||
this.HistoryManager.flushProjectChangesAsync
|
||||
.calledWithExactly(this.project_id)
|
||||
|
|
Loading…
Add table
Reference in a new issue