This commit is contained in:
Shane Kilkelly 2017-03-15 16:07:36 +00:00
parent 3cb0ab2784
commit e99a7f6a87

View file

@ -16,15 +16,12 @@ module.exports = (obj, methodName, key, logger) ->
"[Metrics] expected wrapped method '#{methodName}' to be invoked with a callback" "[Metrics] expected wrapped method '#{methodName}' to be invoked with a callback"
) )
timer = new Metrics.Timer(key) timer = new metrics.Timer(key)
start = new Date() start = new Date()
realMethod.call this, firstArgs, (callbackArgs...) -> realMethod.call this, firstArgs..., (callbackArgs...) ->
timer.done() timer.done()
elapsedTime = new Date() - start elapsedTime = new Date() - start
if logger? if logger?
logger.log logger.log {key, elapsedTime}, "[Metrics] timed async method call"
key: key
time: elapsedTime
"[Metrics] timed async method call"
callback.apply this, callbackArgs callback.apply this, callbackArgs