Kevin Wang (3) [Avatar] Offline
#1
The cloudwatch.js has a function recordTimeInMillis which supposed to log the execution time for an operation. But sometimes the operation is very fast (in my case, the MongoDB's the fetching operation becomes so fast after several calls), which the operation time even equals 0ms. When this happens, the recordTimeInMillis function will just return without logging anything. I changed the code in recordTimeInMillis function from
if (!ms) {
return;
}

to

if (!ms && ms !== 0) {
return;
}

It can help the logging behavior more consistently. I hope this can help others as well.
Yan Cui (71) [Avatar] Offline
#2
Yeah that makes sense, the granularity of the node.js timer module just isn't granular enough in this case. Good call.