perf_hooks: add ReqWrap latency monitoring
Similar to the recently added event loop relay, this adds a perf_hooks.monitorRequestWrapLatency()
API that tracks the length of time between dispatching a ReqWrap and when the callback is invoked. This effectively tracks how long libuv is taking to perform requested actions. No differentiation is made between types of actions. The idea here is to provide a pulse on the general health of the application. If the histogram skews high, then it's taking libuv a longer time to process individual requests.
const { monitorRequestWrapLatency } = require('perf_hooks');
const m = monitorRequestWrapLatency();
m.enable();
// Do stuff
m.disable();
console.log(m.min);
console.log(m.max);
console.log(m.mean);
console.log(m.stddev);
console.log(m.percentile(50));
console.log(m.percentile(99));
console.log(m.percentiles); // Map
Also outputs histogram data to the trace event log.
/cc @mcollina @mafintosh @nodejs/diagnostics
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines