Randomly calls an async fn every roughly latencyCheckIntervalMs (plus some randomness). If no async fn is found, it will simply report on event loop latency.
Emit summary only if there were events. It might not have any events if it was forced via a page hidden/show
Start internal timers
Stop internal timers
This symbol shall be used to install a listener for only monitoring 'error'
events. Listeners installed using this symbol are called before the regular
'error'
listeners are called.
Installing a listener using this symbol does not change the behavior once an
'error'
event is emitted, therefore the process will still crash if no
regular 'error'
listener is installed.
Calling this function will end the collection period. If a timing event was already fired and somewhere in the queue, it will not count for this time period
A class to monitor latency of any async function which works in a browser or node. This works by periodically calling the asyncTestFn and timing how long it takes the callback to be called. It can also periodically emit stats about this. This can be disabled and stats can be pulled via setting dataEmitIntervalMs = 0.
const monitor = new LatencyMonitor(); monitor.on('data', (summary) => console.log('Event Loop Latency: %O', summary));
const monitor = new LatencyMonitor({latencyCheckIntervalMs: 1000, dataEmitIntervalMs: 60000, asyncTestFn:ping}); monitor.on('data', (summary) => console.log('Ping Pong Latency: %O', summary));