Add in new metrics

This commit is contained in:
James Allen 2014-05-09 14:55:37 +01:00
parent abbcea2945
commit 3213c562bc
3 changed files with 8 additions and 22 deletions

View file

@ -4,6 +4,10 @@ logger = require "logger-sharelatex"
logger.initialize("clsi") logger.initialize("clsi")
smokeTest = require "smoke-test-sharelatex" smokeTest = require "smoke-test-sharelatex"
Metrics = require "metrics-sharelatex"
Metrics.initialize("clsi")
Metrics.open_sockets.monitor(logger)
ProjectPersistenceManager = require "./app/js/ProjectPersistenceManager" ProjectPersistenceManager = require "./app/js/ProjectPersistenceManager"
require("./app/js/db").sync() require("./app/js/db").sync()
@ -11,6 +15,8 @@ require("./app/js/db").sync()
express = require "express" express = require "express"
app = express() app = express()
app.use Metrics.http.monitor(logger)
app.post "/project/:project_id/compile", express.bodyParser(), CompileController.compile app.post "/project/:project_id/compile", express.bodyParser(), CompileController.compile
app.del "/project/:project_id", CompileController.clearCache app.del "/project/:project_id", CompileController.clearCache

View file

@ -1,23 +1,2 @@
StatsD = require('lynx') module.exports = require "metrics-sharelatex"
statsd = new StatsD('localhost', 8125, {on_error:->})
buildKey = (key)-> "clsi.#{process.env.NODE_ENV or "testing"}.#{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

@ -12,6 +12,7 @@
"request": "~2.21.0", "request": "~2.21.0",
"logger-sharelatex": "git+https://github.com/sharelatex/logger-sharelatex.git#master", "logger-sharelatex": "git+https://github.com/sharelatex/logger-sharelatex.git#master",
"settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git#master", "settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git#master",
"metrics-sharelatex": "git+https://github.com/sharelatex/metrics-sharelatex.git#master",
"sequelize": "~2.0.0-beta.2", "sequelize": "~2.0.0-beta.2",
"wrench": "~1.5.4", "wrench": "~1.5.4",
"smoke-test-sharelatex": "git+https://github.com/sharelatex/smoke-test-sharelatex.git#master", "smoke-test-sharelatex": "git+https://github.com/sharelatex/smoke-test-sharelatex.git#master",