Bläddra i källkod

Upgrade metrics

Shane Kilkelly 9 år sedan
förälder
incheckning
e67c546254

+ 0 - 1
services/notifications/app.coffee

@@ -9,7 +9,6 @@ db = mongojs(Settings.mongo.url, ['notifications'])
 Path = require("path")
 metrics = require("metrics-sharelatex")
 metrics.initialize("notifications")
-metrics.mongodb.monitor(Path.resolve(__dirname + "/node_modules/mongojs/node_modules/mongodb"), logger)
 metrics.memory.monitor(logger)
 
 HealthCheckController = require("./app/js/HealthCheckController")

+ 14 - 1
services/notifications/app/coffee/Notifications.coffee

@@ -3,8 +3,9 @@ logger = require('logger-sharelatex')
 mongojs = require('mongojs')
 db = mongojs(Settings.mongo?.url, ['notifications'])
 ObjectId = require("mongojs").ObjectId
+metrics = require('metrics-sharelatex')
 
-module.exports =
+module.exports = Notifications =
 
 	getUserNotifications: (user_id, callback = (err, notifications)->)->
 		query =
@@ -79,3 +80,15 @@ module.exports =
 		searchOps =
 			key: notification_key
 		db.notifications.remove searchOps, {justOne: true}, callback
+
+
+metrics.timeAsyncMethod(
+	Notifications, 'getUserNotifications',
+	'Notifications.getUserNotifications',
+	logger
+)
+metrics.timeAsyncMethod(
+	Notifications, 'addNotification',
+	'Notifications.addNotification',
+	logger
+)

+ 1 - 0
services/notifications/test/unit/coffee/NotificationsTests.coffee

@@ -36,6 +36,7 @@ describe 'Notifications Tests', ->
 			}
 			'settings-sharelatex': {}
 			'mongojs':@mongojs
+			'metrics-sharelatex': {timeAsyncMethod: sinon.stub()}
 
 		@stubbedNotification = {user_id: ObjectId(user_id), key:"notification-key", messageOpts:"some info", templateKey:"template-key"}
 		@stubbedNotificationArray = [@stubbedNotification]