Upgrade metrics

This commit is contained in:
Shane Kilkelly 2017-03-17 09:47:45 +00:00
parent c9a9ab93ec
commit e67c546254
3 changed files with 15 additions and 2 deletions

View file

@ -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")

View file

@ -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
)

View file

@ -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]