Upgrade metrics

This commit is contained in:
Shane Kilkelly 2017-03-17 09:31:12 +00:00
parent a565939548
commit 64fc6ef2e3
3 changed files with 18 additions and 3 deletions

View file

@ -9,7 +9,6 @@ Path = require "path"
Metrics.initialize("contacts") Metrics.initialize("contacts")
logger.initialize("contacts") logger.initialize("contacts")
Metrics.mongodb.monitor(Path.resolve(__dirname + "/node_modules/mongojs/node_modules/mongodb"), logger)
Metrics.event_loop?.monitor(logger) Metrics.event_loop?.monitor(logger)
app = express() app = express()

View file

@ -1,4 +1,6 @@
{db, ObjectId} = require "./mongojs" {db, ObjectId} = require "./mongojs"
logger = require('logger-sharelatex')
metrics = require('metrics-sharelatex')
module.exports = ContactManager = module.exports = ContactManager =
touchContact: (user_id, contact_id, callback = (error) ->) -> touchContact: (user_id, contact_id, callback = (error) ->) ->
@ -28,3 +30,15 @@ module.exports = ContactManager =
}, (error, user) -> }, (error, user) ->
return callback(error) if error? return callback(error) if error?
callback null, user?.contacts callback null, user?.contacts
metrics.timeAsyncMethod(
ContactManager, 'touchContact',
'ContactManager.touchContact',
logger
)
metrics.timeAsyncMethod(
ContactManager, 'getContacts',
'ContactManager.getContacts',
logger
)

View file

@ -14,7 +14,9 @@ describe "ContactManager", ->
"./mongojs": { "./mongojs": {
db: @db = contacts: {} db: @db = contacts: {}
ObjectId: ObjectId ObjectId: ObjectId
} },
'logger-sharelatex': {log: sinon.stub()},
'metrics-sharelatex': {timeAsyncMethod: sinon.stub()}
@user_id = ObjectId().toString() @user_id = ObjectId().toString()
@contact_id = ObjectId().toString() @contact_id = ObjectId().toString()
@callback = sinon.stub() @callback = sinon.stub()