elastic / elastic/apm-agent-nodejs

Collect IntervalHistogram of monitorEventLoopDelay

Open
#2,614 0 comments 2 reactions 0 assignees View on GitHub
kibana
Dominant language
JavaScript
Stars
594
Forks
244
Avg merge
1d 8h
Merged PRs (30d)
16

Description

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](https://nodejs.org/docs/latest-v16.x/api/perf_hooks.html#perf_hooksmonitoreventloopdelayoptions) method reporting event loop delay change over time. By default, `perf_hooks.monitorEventLoopDelay` returns [IntervalHistogram](https://nodejs.org/docs/latest-v16.x/api/perf_hooks.html#class-intervalhistogram-extends-histogram) object that groups data by value range buckets. However, the APM agent reports only a single value provided by the `IntervalHistogram` object - [mean](https://github.com/elastic/apm-agent-nodejs/blob/b7cf05a7d3d1b83af3eed86c2e234899815bcb7f/lib/metrics/runtime.js#L42-L43) 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](https://github.com/elastic/apm-agent-nodejs/blob/b7cf05a7d3d1b83af3eed86c2e234899815bcb7f/lib/metrics/runtime.js#L13)). 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).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.