diff --git a/services/clsi/app.coffee b/services/clsi/app.coffee index 5084ffb1ad..7f56d48ab9 100644 --- a/services/clsi/app.coffee +++ b/services/clsi/app.coffee @@ -4,6 +4,10 @@ logger = require "logger-sharelatex" logger.initialize("clsi") smokeTest = require "smoke-test-sharelatex" +Metrics = require "metrics-sharelatex" +Metrics.initialize("clsi") +Metrics.open_sockets.monitor(logger) + ProjectPersistenceManager = require "./app/js/ProjectPersistenceManager" require("./app/js/db").sync() @@ -11,6 +15,8 @@ require("./app/js/db").sync() express = require "express" app = express() +app.use Metrics.http.monitor(logger) + app.post "/project/:project_id/compile", express.bodyParser(), CompileController.compile app.del "/project/:project_id", CompileController.clearCache diff --git a/services/clsi/app/coffee/Metrics.coffee b/services/clsi/app/coffee/Metrics.coffee index 107c5ffc7e..9965b252e4 100644 --- a/services/clsi/app/coffee/Metrics.coffee +++ b/services/clsi/app/coffee/Metrics.coffee @@ -1,23 +1,2 @@ -StatsD = require('lynx') -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 +module.exports = require "metrics-sharelatex" diff --git a/services/clsi/package.json b/services/clsi/package.json index 875e6e8566..6eb8e58729 100644 --- a/services/clsi/package.json +++ b/services/clsi/package.json @@ -12,6 +12,7 @@ "request": "~2.21.0", "logger-sharelatex": "git+https://github.com/sharelatex/logger-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", "wrench": "~1.5.4", "smoke-test-sharelatex": "git+https://github.com/sharelatex/smoke-test-sharelatex.git#master",