Shane Kilkelly 9 лет назад
Родитель
Сommit
64fc6ef2e3

+ 0 - 1
services/contacts/app.coffee

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

+ 15 - 1
services/contacts/app/coffee/ContactManager.coffee

@@ -1,4 +1,6 @@
 {db, ObjectId} = require "./mongojs"
+logger = require('logger-sharelatex')
+metrics = require('metrics-sharelatex')
 
 module.exports = ContactManager =
 	touchContact: (user_id, contact_id, callback = (error) ->) ->
@@ -27,4 +29,16 @@ module.exports = ContactManager =
 			user_id: user_id
 		}, (error, user) ->
 			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
+)

+ 3 - 1
services/contacts/test/unit/coffee/ContactsManagerTests.coffee

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