mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Upgrade metrics api
This commit is contained in:
parent
5e112043ca
commit
a64f890ed0
7 changed files with 37 additions and 11 deletions
|
@ -11,7 +11,8 @@ fs = require('fs')
|
||||||
Path = require "path"
|
Path = require "path"
|
||||||
_ = require "underscore"
|
_ = require "underscore"
|
||||||
|
|
||||||
module.exports =
|
module.exports = ProjectCreationHandler =
|
||||||
|
|
||||||
createBlankProject : (owner_id, projectName, callback = (error, project) ->)->
|
createBlankProject : (owner_id, projectName, callback = (error, project) ->)->
|
||||||
metrics.inc("project-creation")
|
metrics.inc("project-creation")
|
||||||
logger.log owner_id:owner_id, projectName:projectName, "creating blank project"
|
logger.log owner_id:owner_id, projectName:projectName, "creating blank project"
|
||||||
|
@ -79,5 +80,10 @@ module.exports =
|
||||||
output = _.template(template.toString(), data)
|
output = _.template(template.toString(), data)
|
||||||
callback null, output.split("\n")
|
callback null, output.split("\n")
|
||||||
|
|
||||||
|
metrics.timeAsyncMethod(
|
||||||
|
ProjectCreationHandler, 'createBlankProject',
|
||||||
|
'mongo.ProjectCreationHandler',
|
||||||
|
logger
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -60,4 +60,8 @@ module.exports = ProjectGetter =
|
||||||
callback null, projects, readAndWriteProjects, readOnlyProjects
|
callback null, projects, readAndWriteProjects, readOnlyProjects
|
||||||
|
|
||||||
|
|
||||||
metrics.timeAsyncMethod ProjectGetter, 'getProject', 'ProjectGetter.getProject', logger
|
[
|
||||||
|
'getProject',
|
||||||
|
'getProjectWithoutDocLines'
|
||||||
|
].map (method) ->
|
||||||
|
metrics.timeAsyncMethod(ProjectGetter, method, 'mongo.ProjectGetter', logger)
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
User = require("../../models/User").User
|
User = require("../../models/User").User
|
||||||
UserLocator = require("./UserLocator")
|
UserLocator = require("./UserLocator")
|
||||||
logger = require("logger-sharelatex")
|
logger = require("logger-sharelatex")
|
||||||
|
metrics = require('../../infrastructure/Metrics')
|
||||||
|
|
||||||
module.exports =
|
|
||||||
|
module.exports = UserCreator =
|
||||||
|
|
||||||
getUserOrCreateHoldingAccount: (email, callback = (err, user)->)->
|
getUserOrCreateHoldingAccount: (email, callback = (err, user)->)->
|
||||||
self = @
|
self = @
|
||||||
|
@ -36,3 +38,9 @@ module.exports =
|
||||||
|
|
||||||
user.save (err)->
|
user.save (err)->
|
||||||
callback(err, user)
|
callback(err, user)
|
||||||
|
|
||||||
|
metrics.timeAsyncMethod(
|
||||||
|
UserCreator, 'createNewUser',
|
||||||
|
'mongo.UserCreator',
|
||||||
|
logger
|
||||||
|
)
|
||||||
|
|
|
@ -27,5 +27,9 @@ module.exports = UserGetter =
|
||||||
|
|
||||||
db.users.find { _id: { $in: user_ids} }, projection, callback
|
db.users.find { _id: { $in: user_ids} }, projection, callback
|
||||||
|
|
||||||
metrics.timeAsyncMethod UserGetter, 'getUser', 'UserGetter.getUser', logger
|
|
||||||
metrics.timeAsyncMethod UserGetter, 'getUsers', 'UserGetter.getUsers', logger
|
[
|
||||||
|
'getUser',
|
||||||
|
'getUsers'
|
||||||
|
].map (method) ->
|
||||||
|
metrics.timeAsyncMethod UserGetter, method, 'mongo.UserGetter', logger
|
||||||
|
|
|
@ -14,5 +14,8 @@ module.exports = UserLocator =
|
||||||
findById: (_id, callback)->
|
findById: (_id, callback)->
|
||||||
db.users.findOne _id:ObjectId(_id+""), callback
|
db.users.findOne _id:ObjectId(_id+""), callback
|
||||||
|
|
||||||
metrics.timeAsyncMethod UserLocator, 'findById', 'UserLocator.findById', logger
|
[
|
||||||
metrics.timeAsyncMethod UserLocator, 'findByEmail', 'UserLocator.findByEmail', logger
|
'findById',
|
||||||
|
'findByEmail'
|
||||||
|
].map (method) ->
|
||||||
|
metrics.timeAsyncMethod UserLocator, method, 'mongo.UserLocator', logger
|
||||||
|
|
|
@ -30,4 +30,4 @@ module.exports = UserUpdater =
|
||||||
callback()
|
callback()
|
||||||
|
|
||||||
|
|
||||||
metrics.timeAsyncMethod UserUpdater, 'updateUser', 'UserUpdater.updateUser', logger
|
metrics.timeAsyncMethod UserUpdater, 'updateUser', 'mongo.UserUpdater', logger
|
||||||
|
|
|
@ -50,9 +50,10 @@ describe 'ProjectCreationHandler', ->
|
||||||
'./ProjectEntityHandler':@ProjectEntityHandler
|
'./ProjectEntityHandler':@ProjectEntityHandler
|
||||||
"settings-sharelatex": @Settings = {}
|
"settings-sharelatex": @Settings = {}
|
||||||
'logger-sharelatex': {log:->}
|
'logger-sharelatex': {log:->}
|
||||||
"../../infrastructure/Metrics": inc:->
|
"../../infrastructure/Metrics": {
|
||||||
|
inc: ()->,
|
||||||
|
timeAsyncMethod: ()->
|
||||||
|
}
|
||||||
|
|
||||||
describe 'Creating a Blank project', ->
|
describe 'Creating a Blank project', ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
|
Loading…
Reference in a new issue