Log args and their indexes, if they look like object ids

This commit is contained in:
Shane Kilkelly 2017-03-17 14:20:13 +00:00
parent e7f71a25d8
commit be2c6a96af

View file

@ -21,5 +21,10 @@ module.exports = (obj, methodName, prefix, logger) ->
realMethod.call this, firstArgs..., (callbackArgs...) -> realMethod.call this, firstArgs..., (callbackArgs...) ->
elapsedTime = timer.done() elapsedTime = timer.done()
if logger? if logger?
logger.log {key, elapsedTime}, "[Metrics] timed async method call" loggableArgs = {}
try
for arg, idx in firstArgs
if arg.toString().match(/^[0-9a-f]{24}$/)
loggableArgs["#{idx}"] = arg
logger.log {key, args: loggableArgs, elapsedTime}, "[Metrics] timed async method call"
callback.apply this, callbackArgs callback.apply this, callbackArgs