Update to new metrics api

This commit is contained in:
Shane Kilkelly 2017-03-17 14:58:35 +00:00
parent c30e672549
commit fa7ee739bb
2 changed files with 8 additions and 12 deletions

View file

@ -3,6 +3,7 @@ PackManager = require "./PackManager"
async = require "async"
_ = require "underscore"
metrics = require 'metrics-sharelatex'
logger = require 'logger-sharelatex'
module.exports = MongoManager =
getLastCompressedUpdate: (doc_id, callback = (error, update) ->) ->
@ -95,15 +96,9 @@ module.exports = MongoManager =
db.docHistoryIndex.ensureIndex { project_id: 1 }, { background: true }
metrics.timeAsyncMethod(
MongoManager, 'getLastCompressedUpdate',
'MongoManger.getLastCompressedUpdate'
)
metrics.timeAsyncMethod(
MongoManager, 'getProjectMetaData',
'MongoManger.getProjectMetaData'
)
metrics.timeAsyncMethod(
MongoManager, 'setProjectMetaData',
'MongoManger.setProjectMetaData'
)
[
'getLastCompressedUpdate',
'getProjectMetaData',
'setProjectMetaData'
].map (method) ->
metrics.timeAsyncMethod(MongoManager, method, 'mongo.MongoManager', logger)

View file

@ -14,6 +14,7 @@ describe "MongoManager", ->
@MongoManager = SandboxedModule.require modulePath, requires:
"./mongojs" : { db: @db = {}, ObjectId: ObjectId }
"./PackManager" : @PackManager = {}
'metrics-sharelatex': {timeAsyncMethod: ()->}
@callback = sinon.stub()
@doc_id = ObjectId().toString()
@project_id = ObjectId().toString()