Improve duration accuracy for coldstarts
AWS charges and reports the time of a function as including the coldstart initialization time. We do not detect the time spent during initialization and thus do not report this within the duration. This causes duration inaccuracies for coldstarts.
We could add logic that adjusts the duration reported when we're sending a report which is also a coldstart. In this case, we would set the recorded startTime according to the process start time, not when the user's function was invoked.
There is a nice side effect of the current implementation though... visibility into how much of the time was spent initializing the coldstart vs the code execution. We could maybe capture both of these?
Recording the coldstart time within auto-tracing might be a solution to showing the initialization time? This is what Xray does iirc.
Perhaps if it's a coldstart the duration should be reported as simply the process.uptime? (this is expressed as seconds with milliseconds represented via decimal and would need to be converted)
https://nodejs.org/api/process.html#process_process_uptime