Merge branch 'sk-upgrade-metrics'

This commit is contained in:
Shane Kilkelly 2017-04-04 09:34:45 +01:00
commit 6a6fdc13a5
4 changed files with 19 additions and 4 deletions

View file

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

View file

@ -1,4 +1,6 @@
{db, ObjectId} = require "./mongojs"
logger = require 'logger-sharelatex'
metrics = require 'metrics-sharelatex'
module.exports = MongoManager =
@ -67,4 +69,16 @@ module.exports = MongoManager =
$set: version: version
}, {
upsert: true
}, callback
}, callback
[
'findDoc',
'getProjectsDocs',
'getArchivedProjectDocs',
'upsertIntoDocCollection',
'markDocAsArchived',
'getDocVersion',
'setDocVersion'
].map (method) ->
metrics.timeAsyncMethod(MongoManager, method, 'mongo.MongoManager', logger)

View file

@ -10,7 +10,7 @@
"dependencies": {
"settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git#v1.0.0",
"logger-sharelatex": "git+https://github.com/sharelatex/logger-sharelatex.git#v1.4.0",
"metrics-sharelatex": "git+https://github.com/sharelatex/metrics-sharelatex.git#v1.1.0",
"metrics-sharelatex": "git+https://github.com/sharelatex/metrics-sharelatex.git#v1.7.1",
"mongojs": "0.18.2",
"express": "~4.1.1",
"underscore": "~1.6.0",

View file

@ -11,6 +11,8 @@ describe "MongoManager", ->
"./mongojs":
db: @db = { docs: {}, docOps: {} }
ObjectId: ObjectId
'metrics-sharelatex': {timeAsyncMethod: sinon.stub()}
'logger-sharelatex': {log: ()->}
@project_id = ObjectId().toString()
@doc_id = ObjectId().toString()
@callback = sinon.stub()
@ -151,4 +153,4 @@ describe "MongoManager", ->
.should.equal true
it "should call the callback", ->
@callback.called.should.equal true
@callback.called.should.equal true