upgrade metrics

This commit is contained in:
Shane Kilkelly 2017-03-16 16:08:57 +00:00
parent 47e501ba2c
commit f58f256864
3 changed files with 57 additions and 2 deletions

View file

@ -2,6 +2,8 @@ mongojs = require "../../mongojs"
db = mongojs.db db = mongojs.db
ObjectId = mongojs.ObjectId ObjectId = mongojs.ObjectId
async = require "async" async = require "async"
metrics = require 'metrics-sharelatex'
logger = require 'logger-sharelatex'
module.exports = MessageManager = module.exports = MessageManager =
createMessage: (room_id, user_id, content, timestamp, callback = (error, message) ->) -> createMessage: (room_id, user_id, content, timestamp, callback = (error, message) ->) ->
@ -63,3 +65,29 @@ module.exports = MessageManager =
query._id = ObjectId(query._id) query._id = ObjectId(query._id)
return query return query
metrics.timeAsyncMethod(
MessageManager, 'createMessage',
'MessageManager.createMessage',
logger
)
metrics.timeAsyncMethod(
MessageManager, 'getMessages',
'MessageManager.getMessages',
logger
)
metrics.timeAsyncMethod(
MessageManager, 'findAllMessagesInRooms',
'MessageManager.findAllMessagesInRooms',
logger
)
metrics.timeAsyncMethod(
MessageManager, 'updateMessage',
'MessageManager.updateMessage',
logger
)
metrics.timeAsyncMethod(
MessageManager, 'deleteMessage',
'MessageManager.deleteMessage',
logger
)

View file

@ -1,6 +1,8 @@
mongojs = require("../../mongojs") mongojs = require("../../mongojs")
db = mongojs.db db = mongojs.db
ObjectId = mongojs.ObjectId ObjectId = mongojs.ObjectId
logger = require('logger-sharelatex')
metrics = require('metrics-sharelatex')
module.exports = ThreadManager = module.exports = ThreadManager =
GLOBAL_THREAD: "GLOBAL" GLOBAL_THREAD: "GLOBAL"
@ -74,3 +76,30 @@ module.exports = ThreadManager =
}, (error) -> }, (error) ->
return callback(error) if error? return callback(error) if error?
return callback null, room._id return callback null, room._id
metrics.timeAsyncMethod(
ThreadManager, 'findOrCreateThread',
'ThreadManager.findOrCreateThread',
logger
)
metrics.timeAsyncMethod(
ThreadManager, 'findAllThreadRooms',
'ThreadManager.findAllThreadRooms',
logger
)
metrics.timeAsyncMethod(
ThreadManager, 'resolveThread',
'ThreadManager.resolveThread',
logger
)
metrics.timeAsyncMethod(
ThreadManager, 'reopenThread',
'ThreadManager.reopenThread',
logger
)
metrics.timeAsyncMethod(
ThreadManager, 'deleteThread',
'ThreadManager.deleteThread',
logger
)

View file

@ -8,8 +8,6 @@ app = express()
server = require("http").createServer(app) server = require("http").createServer(app)
Router = require "./router" Router = require "./router"
metrics.mongodb.monitor(Path.resolve(__dirname + "/../../node_modules/mongojs/node_modules/mongodb"), logger)
app.use express.bodyParser() app.use express.bodyParser()
app.use metrics.http.monitor(logger) app.use metrics.http.monitor(logger)