Tag observability

How to gather GC metrics in NodeJS

We can trace NodeJS GC by using node --trace-gc app.js And use the performance tool to get the data in runtime. const { PerformanceObserver } = require('perf_hooks'); // Create a performance observer const obs = new PerformanceObserver((list) => { const entry = list.getEntries()[0] /* The entry would be an instance of PerformanceEntry containing metrics of garbage collection. For example: PerformanceEntry { name: 'gc', entryType: 'gc', startTime: 2820.567669, duration: 1.315709, kind: 1 } */ }); // Subscribe notifications of GCs obs.