From 3bbeff5aff1ab8e50e5087bbaa4e969bf8f9e371 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Mon, 12 May 2014 15:45:15 +0100 Subject: [PATCH] moved all metrics to use the module, deleting old metrics file and added different check in err domain --- services/filestore/app.coffee | 3 ++- .../app/coffee/FileController.coffee | 2 +- .../filestore/app/coffee/FileConverter.coffee | 2 +- .../app/coffee/LocalFileWriter.coffee | 2 +- services/filestore/app/coffee/metrics.coffee | 24 ------------------- 5 files changed, 5 insertions(+), 28 deletions(-) delete mode 100644 services/filestore/app/coffee/metrics.coffee diff --git a/services/filestore/app.coffee b/services/filestore/app.coffee index d5d0e1a459..03daabaa19 100644 --- a/services/filestore/app.coffee +++ b/services/filestore/app.coffee @@ -37,8 +37,9 @@ app.use (req, res, next) -> requestDomain.add req requestDomain.add res requestDomain.on "error", (err)-> + metrics.inc "err.uncaught" setTimeout(-> - if !res.finished + if !res.headerSent res.send(500) , 3000) logger = require('logger-sharelatex') diff --git a/services/filestore/app/coffee/FileController.coffee b/services/filestore/app/coffee/FileController.coffee index 2beaef8a96..3b83e203fd 100644 --- a/services/filestore/app/coffee/FileController.coffee +++ b/services/filestore/app/coffee/FileController.coffee @@ -2,7 +2,7 @@ PersistorManager = require("./PersistorManager") settings = require("settings-sharelatex") logger = require("logger-sharelatex") FileHandler = require("./FileHandler") -metrics = require("./metrics") +metrics = require("metrics-sharelatex") oneDayInSeconds = 60 * 60 * 24 module.exports = diff --git a/services/filestore/app/coffee/FileConverter.coffee b/services/filestore/app/coffee/FileConverter.coffee index c96b805180..0d6eb0d9f3 100644 --- a/services/filestore/app/coffee/FileConverter.coffee +++ b/services/filestore/app/coffee/FileConverter.coffee @@ -1,5 +1,5 @@ _ = require("underscore") -metrics = require("./metrics") +metrics = require("metrics-sharelatex") logger = require("logger-sharelatex") exec = require('child_process').exec approvedFormats = ["png"] diff --git a/services/filestore/app/coffee/LocalFileWriter.coffee b/services/filestore/app/coffee/LocalFileWriter.coffee index bf0c0fd82f..71cbb32622 100644 --- a/services/filestore/app/coffee/LocalFileWriter.coffee +++ b/services/filestore/app/coffee/LocalFileWriter.coffee @@ -3,7 +3,7 @@ uuid = require('node-uuid') path = require("path") _ = require("underscore") logger = require("logger-sharelatex") -metrics = require("./metrics") +metrics = require("metrics-sharelatex") module.exports = diff --git a/services/filestore/app/coffee/metrics.coffee b/services/filestore/app/coffee/metrics.coffee deleted file mode 100644 index cd5c7ab215..0000000000 --- a/services/filestore/app/coffee/metrics.coffee +++ /dev/null @@ -1,24 +0,0 @@ -StatsD = require('lynx') -settings = require('settings-sharelatex') -statsd = new StatsD('localhost', 8125, {on_error:->}) - -buildKey = (key)-> "filestore.#{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 -