small cleanup

This commit is contained in:
Henry Oswald 2018-12-04 17:01:30 +00:00
parent 85d4b03bcb
commit 93f4a7eeaf
3 changed files with 3 additions and 7 deletions

View file

@ -10,8 +10,6 @@ module.exports.monitor = (logger) ->
responseTime = new Date() - startTime
if req.route?.path?
routePath = req.route.path.toString().replace(/\//g, '_').replace(/\:/g, '').slice(1)
key = "http-requests.#{routePath}.#{req.method}.#{res.statusCode}"
Metrics.timing("http_request", responseTime, null, {method:req.method, status_code: res.statusCode, path:routePath})
logger.log
req:

View file

@ -11,8 +11,6 @@ hostname = require('os').hostname()
buildKey = (key)-> "#{name}.#{hostname}.#{key}"
buildGlobalKey = (key)-> "#{name}.global.#{key}"
promMetrics = {}
destructors = []

View file

@ -25,15 +25,15 @@ module.exports = (obj, methodName, prefix, logger) ->
logger.log "[Metrics] expected wrapped method '#{methodName}' to be invoked with a callback"
return realMethod.apply this, originalArgs
timer = new metrics.Timer(startPrefix, null, {method: modifedMethodName})
timer = new metrics.Timer(startPrefix, 1, {method: modifedMethodName})
realMethod.call this, firstArgs..., (callbackArgs...) ->
elapsedTime = timer.done()
possibleError = callbackArgs[0]
if possibleError?
metrics.inc "#{startPrefix}_result", null, {status:"failed", method: modifedMethodName}
metrics.inc "#{startPrefix}_result", 1, {status:"failed", method: modifedMethodName}
else
metrics.inc "#{startPrefix}_result", null, {status:"success", method: modifedMethodName}
metrics.inc "#{startPrefix}_result", 1, {status:"success", method: modifedMethodName}
if logger?
loggableArgs = {}
try