From 7a377350e8384ab8466083383b7b3bef0cff0879 Mon Sep 17 00:00:00 2001 From: Rob Date: Tue, 17 Nov 2015 15:19:17 -0800 Subject: [PATCH] Tabs -> Spaces --- server/commons/perfmon.coffee | 54 +++++++++++++++++------------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/server/commons/perfmon.coffee b/server/commons/perfmon.coffee index e03b6145f..8d66ba853 100644 --- a/server/commons/perfmon.coffee +++ b/server/commons/perfmon.coffee @@ -4,40 +4,40 @@ config = require '../../server_config' StatsD = require 'node-statsd' if config.statsd - realClient = new StatsD(config.statsd) + realClient = new StatsD(config.statsd) else - mock = new StatsD(mock: true) + mock = new StatsD(mock: true) exports.client = realClient or mock exports.middleware = (req, res, next) -> - req.statsd = exports.client - if realClient - time = process.hrtime(); - cleanup = -> - res.removeListener 'finish', recordMetrics - res.removeListener 'error', cleanup - res.removeListener 'close', cleanup + req.statsd = exports.client + if realClient + time = process.hrtime(); + cleanup = -> + res.removeListener 'finish', recordMetrics + res.removeListener 'error', cleanup + res.removeListener 'close', cleanup - recordMetrics = -> - diff = process.hrtime(time); - ms = (diff[0] * 1000 + diff[1] / 1e6); - path = req.route?.path or '/*' - stat = req.method + "." + path.replace /[^A-Za-z0-9]+/g, '_' - realClient.timing stat, ms - + recordMetrics = -> + diff = process.hrtime(time); + ms = (diff[0] * 1000 + diff[1] / 1e6); + path = req.route?.path or '/*' + stat = req.method + "." + path.replace /[^A-Za-z0-9]+/g, '_' + realClient.timing stat, ms + - res.once 'finish', recordMetrics - res.once 'error', cleanup - res.once 'close', cleanup - else - req.statsd = mock + res.once 'finish', recordMetrics + res.once 'error', cleanup + res.once 'close', cleanup + else + req.statsd = mock - next() unless not next + next() unless not next exports.trace = (name, callback) -> - return callback unless realClient - time = process.hrtime() - (args...) -> - realClient.timing name, ms - return callback.apply(this, args) \ No newline at end of file + return callback unless realClient + time = process.hrtime() + (args...) -> + realClient.timing name, ms + return callback.apply(this, args) \ No newline at end of file