mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-01 15:11:30 -05:00
add metrics for history flushes
This commit is contained in:
parent
e2c75b43ba
commit
b7055eecee
2 changed files with 4 additions and 1 deletions
|
@ -5,13 +5,14 @@ Settings = require "settings-sharelatex"
|
||||||
HistoryRedisManager = require "./HistoryRedisManager"
|
HistoryRedisManager = require "./HistoryRedisManager"
|
||||||
ProjectHistoryRedisManager = require "./ProjectHistoryRedisManager"
|
ProjectHistoryRedisManager = require "./ProjectHistoryRedisManager"
|
||||||
RedisManager = require "./RedisManager"
|
RedisManager = require "./RedisManager"
|
||||||
|
metrics = require "./Metrics"
|
||||||
|
|
||||||
module.exports = HistoryManager =
|
module.exports = HistoryManager =
|
||||||
flushDocChangesAsync: (project_id, doc_id) ->
|
flushDocChangesAsync: (project_id, doc_id) ->
|
||||||
if !Settings.apis?.trackchanges?
|
if !Settings.apis?.trackchanges?
|
||||||
logger.warn { doc_id }, "track changes API is not configured, so not flushing"
|
logger.warn { doc_id }, "track changes API is not configured, so not flushing"
|
||||||
return
|
return
|
||||||
|
metrics.inc 'history-flush', 1, { status: 'track-changes'}
|
||||||
url = "#{Settings.apis.trackchanges.url}/project/#{project_id}/doc/#{doc_id}/flush"
|
url = "#{Settings.apis.trackchanges.url}/project/#{project_id}/doc/#{doc_id}/flush"
|
||||||
logger.log { project_id, doc_id, url }, "flushing doc in track changes api"
|
logger.log { project_id, doc_id, url }, "flushing doc in track changes api"
|
||||||
request.post url, (error, res, body)->
|
request.post url, (error, res, body)->
|
||||||
|
@ -31,6 +32,7 @@ module.exports = HistoryManager =
|
||||||
if options.skip_history_flush
|
if options.skip_history_flush
|
||||||
logger.log {project_id}, "skipping flush of project history"
|
logger.log {project_id}, "skipping flush of project history"
|
||||||
return callback()
|
return callback()
|
||||||
|
metrics.inc 'history-flush', 1, { status: 'project-history'}
|
||||||
url = "#{Settings.apis.project_history.url}/project/#{project_id}/flush"
|
url = "#{Settings.apis.project_history.url}/project/#{project_id}/flush"
|
||||||
qs = {}
|
qs = {}
|
||||||
qs.background = true if options.background # pass on the background flush option if present
|
qs.background = true if options.background # pass on the background flush option if present
|
||||||
|
|
|
@ -20,6 +20,7 @@ describe "HistoryManager", ->
|
||||||
"./HistoryRedisManager": @HistoryRedisManager = {}
|
"./HistoryRedisManager": @HistoryRedisManager = {}
|
||||||
"./RedisManager": @RedisManager = {}
|
"./RedisManager": @RedisManager = {}
|
||||||
"./ProjectHistoryRedisManager": @ProjectHistoryRedisManager = {}
|
"./ProjectHistoryRedisManager": @ProjectHistoryRedisManager = {}
|
||||||
|
"./Metrics": @metrics = {inc: sinon.stub()}
|
||||||
@project_id = "mock-project-id"
|
@project_id = "mock-project-id"
|
||||||
@doc_id = "mock-doc-id"
|
@doc_id = "mock-doc-id"
|
||||||
@callback = sinon.stub()
|
@callback = sinon.stub()
|
||||||
|
|
Loading…
Reference in a new issue