New Relic's Node.js agent collects key metric timeslice data from the Node.js virtual machine (VM). These metrics give you insight into Node.js VM behavior and help you improve your application's performance. The agent also collects CPU metrics, which are often analyzed together with garbage collection (GC) metrics.
What you need
As of agent release 14.11.0, the agent ships with a JavaScript native VM metrics collection routine directly within the agent. Prior to this release, the agent required an additional native module to collect Node.js VM metric timeslice data related to garbage collection, memory, and CPU.
We recommend updating to the latest agent release in order to take advantage of the built-in metrics collection. The remainder of this document will assume such, and will not reference the decommissioned native module.
Not all data can be collected across all Node.js versions. In general, you will get the most complete data if you are on the most recent LTS version of Node.
The amount of time spent in garbage collection (all types used by V8) by your Node.js process. Time is measured both as a cumulative metric, as GC/System/Pauses, and bucketed by garbage collection type as GC/<type>.
Possible garbage collection types include:
GC type
Description
Scavenge
The most common garbage collection method. Node.js will typically trigger one of these every time the VM is idle.
MarkSweepCompact
The heaviest type of garbage collection V8 may do. If you see many of these happening you will need to either keep fewer objects around in your process or increase V8's heap limit.
IncrementalMarking
A phased garbage collection that interleaves collection with application logic to reduce the amount of time the application is paused. Only in Node.js v6 or higher.
ProcessWeakCallbacks
After a garbage collection occurs, V8 will call any weak reference callbacks registered for objects that have been freed. This measurement is from the start of the first weak callback to the end of the last for a given garbage collection. Only in Node.js v6 or higher.
The New Relic Node.js agent collects the following metrics related to memory usage:
Metric
Description
Memory/Physical
The total physical memory (in MB) used by the Node.js process. It is recorded using the process.memoryUsage().rss Node.js API.
Memory/Heap/Max
The total heap (in MB) allocated by V8 for storing Javascript objects. It is recorded using the process.memoryUsage().heapTotal Node.js API.
Memory/Heap/Used
The amount of V8 heap (in MB) currently used by the app. It is recorded using the process.memoryUsage().heapUsed Node.js API.
Memory/Heap/Free
The amount of V8 memory (in MB) that is allocated but not used. This is a derived metric (heapTotal - heapUsed).
Memory/NonHeap/Used
The amount of memory other than V8 heap (in MB). This is a derived metric (rss - heapTotal). This metric is useful for finding memory leaks outside of V8 heap; for example, with buffers or streams.
The agent collects the following metrics related to CPU:
Metric
Description
CPU/User Time
The time spent by CPU executing the user code. It is recorded in seconds.
CPU/User/Utilization
The time spent executing the user code (CPU/User Time) divided by wall clock time and the number of logical processors. Because the Node.js runtime always uses only one core, the max value reported by this metric will be 100 divided by the number of cores.
CPU/System Time
The time spent by CPU in the system kernel in relation to the Node.js process.
CPU/System/Utilization
The time spent in the system kernel (CPU/System Time) divided by wall clock time and the number of logical processors. Because the Node.js runtime always uses only one core, the max value reported by this metric will be 100 divided by number of cores.
The agent collects the following event loop metrics:
Metric
Description
Nodejs/EventLoop/CPU/Usage
The total CPU time spent actively executing in each event loop tick. This includes executing your application's callbacks, but also the runtime itself. Reported in units of seconds.
An abnormally long event loop tick indicates unbroken synchronous execution that may be a target for optimization; for example, recursive process.nextTick calls).