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") Metrics.initialize("docstore")
logger.initialize("docstore") logger.initialize("docstore")
Metrics.mongodb.monitor(Path.resolve(__dirname + "/node_modules/mongojs/node_modules/mongodb"), logger)
Metrics.event_loop?.monitor(logger) Metrics.event_loop?.monitor(logger)
app = express() app = express()

View file

@ -1,4 +1,6 @@
{db, ObjectId} = require "./mongojs" {db, ObjectId} = require "./mongojs"
logger = require 'logger-sharelatex'
metrics = require 'metrics-sharelatex'
module.exports = MongoManager = module.exports = MongoManager =
@ -67,4 +69,16 @@ module.exports = MongoManager =
$set: version: version $set: version: version
}, { }, {
upsert: true 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": { "dependencies": {
"settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git#v1.0.0", "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", "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", "mongojs": "0.18.2",
"express": "~4.1.1", "express": "~4.1.1",
"underscore": "~1.6.0", "underscore": "~1.6.0",

View file

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