Collect IntervalHistogram of monitorEventLoopDelay
The APM agent collects some runtime metrics. Event loop delay is one of them. When it's possible, the APM agent relies on the nodejs built-in functionality - perf_hooks.monitorEventLoopDelay method reporting event loop delay change over time. By default, perf_hooks.monitorEventLoopDelay returns IntervalHistogram object that groups data by value range buckets. However, the APM agent reports only a single value provided by the IntervalHistogram object - mean value. It means that any deviations and spikes will not be reported. In general, this is not a problem, provided that the sample rate remains small (now it is 10 ms). But if in the future we will collect metrics less often, the reported mean value will greatly skew the picture, smoothing out all the spikes and dips.
Describe the solution you'd like There are a few different options. We could either report the whole histogram object, which comes with the cost of storing the additional amount of data. Or we can report a more aggressive metric to cover as many samples as possible (90th or 95th percentile, for example).