Merge pull request #2 from EDP-Sciences/master

Remove the internal metrics module.
This commit is contained in:
Henry Oswald 2015-11-19 16:32:14 +00:00
commit 0e20cb36fd
6 changed files with 11 additions and 36 deletions

View file

@ -1,5 +1,5 @@
logger = require "logger-sharelatex"
metrics = require "../../metrics"
metrics = require "metrics-sharelatex"
MessageManager = require "./MessageManager"
MessageFormatter = require "./MessageFormatter"
SocketManager = require "../Sockets/SocketManager"

View file

@ -1,5 +1,5 @@
logger = require "logger-sharelatex"
metrics = require "../../metrics"
metrics = require "metrics-sharelatex"
MessageManager = require "./MessageManager"
MessageFormatter = require "./MessageFormatter"
RoomManager = require "../Rooms/RoomManager"

View file

@ -1,22 +0,0 @@
StatsD = require('lynx')
statsd = new StatsD('localhost', 8125, {on_error:->})
buildKey = (key)-> "chat.#{process.env.NODE_ENV}.#{key}"
module.exports =
set : (key, value, sampleRate = 1)->
statsd.set buildKey(key), value, sampleRate
inc : (key, sampleRate = 1)->
statsd.increment buildKey(key), sampleRate
Timer : class
constructor :(key, sampleRate = 1)->
this.start = new Date()
this.key = buildKey(key)
done:->
timeSpan = new Date - this.start
statsd.timing(this.key, timeSpan, this.sampleRate)
gauge : (key, value, sampleRate = 1)->
statsd.gauge key, value, sampleRate

View file

@ -13,16 +13,15 @@ Router = require "./router"
metrics.mongodb.monitor(Path.resolve(__dirname + "/../../node_modules/mongojs/node_modules/mongodb"), logger)
app.configure ()->
app.use express.bodyParser()
app.use metrics.http.monitor(logger)
Router.route(app, io)
app.use express.bodyParser()
app.use metrics.http.monitor(logger)
Router.route(app, io)
app.configure 'development', ->
if (app.get 'env') == 'development'
console.log "Development Enviroment"
app.use express.errorHandler({ dumpExceptions: true, showStack: true })
app.configure 'production', ->
if (app.get 'env') == 'production'
console.log "Production Enviroment"
app.use express.logger()
app.use express.errorHandler()

View file

@ -9,18 +9,14 @@
"dependencies": {
"async": "0.2.9",
"express": "3.3.1",
"lynx": "0.0.11",
"request": "2.21.0",
"socket.io": "0.9.14",
"settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git#v1.0.0",
"logger-sharelatex": "git+https://github.com/sharelatex/logger-sharelatex.git#master",
"metrics-sharelatex": "git+https://github.com/sharelatex/metrics-sharelatex.git#v1.0.0",
"grunt-requirejs": "~0.4.0",
"grunt-mocha-test": "~0.8.0",
"mongojs": "0.18.2",
"redis": "~0.10.1",
"coffee-script": "~1.7.1",
"timekeeper": "0.0.4"
"coffee-script": "~1.7.1"
},
"devDependencies": {
"bunyan": "^1.0.0",
@ -36,6 +32,8 @@
"grunt-contrib-requirejs": "~0.4.1",
"grunt-contrib-uglify": "~0.2.7",
"grunt-contrib-watch": "~0.5.3",
"grunt-requirejs": "~0.4.0",
"grunt-mocha-test": "~0.8.0",
"grunt-execute": "^0.2.2",
"grunt-nodemon": "~0.1.2",
"grunt-notify": "~0.2.16",

View file

@ -17,7 +17,7 @@ describe "MessageController", ->
"../Sockets/SocketManager": @SocketManager = {}
"../Authorization/AuthorizationManager": @AuthorizationManager = {}
"logger-sharelatex": @logger = { log: sinon.stub() }
"../../metrics": @metrics = {inc: sinon.stub()}
"metrics-sharelatex": @metrics = {inc: sinon.stub()}
@callback = sinon.stub()
@client =
params: