Skip to main content
The Datadog Continuous Profiler collects performance profiles from your running Node.js application and uploads them to Datadog, where you can visualise flame graphs, identify hot code paths, and correlate profiling data with traces.

Profile types

The Node.js profiler collects the following profile types:

Wall time

Samples the call stack at regular intervals regardless of CPU state. Includes time spent in I/O, timers, and awaiting callbacks. Best for understanding overall latency.

CPU time

Measures time the CPU actively spends executing JavaScript. Useful for identifying compute-intensive code.

Heap allocation

Tracks object allocations by sampling the call stack at allocation time. Helps identify memory-hungry code paths and memory leaks.

Heap live objects

Snapshots live objects in the V8 heap at the end of each profiling interval. Useful for understanding memory usage patterns.
CPU profiling is enabled by default. Heap profiling can be enabled separately with DD_PROFILING_HEAP_ENABLED=true.

Enabling the profiler

1

Set the environment variable

DD_PROFILING_ENABLED=true node server.js
2

Or enable programmatically

Pass profiling: true to tracer.init():
const tracer = require('dd-trace').init({
  service: 'my-service',
  env: 'production',
  profiling: true,
})
3

Enable heap profiling (optional)

Heap profiling is disabled by default:
DD_PROFILING_ENABLED=true DD_PROFILING_HEAP_ENABLED=true node server.js
4

View profiles in Datadog

Profiles appear in APM > Continuous Profiler within a minute or two of startup.

Configuration

Environment variableDefaultDescription
DD_PROFILING_ENABLEDfalseEnable the profiler
DD_PROFILING_CPU_ENABLEDtrueEnable CPU / wall-time profiling
DD_PROFILING_HEAP_ENABLEDfalseEnable heap allocation profiling
DD_PROFILING_WALLTIME_ENABLEDtrueEnable wall-time profiling
DD_PROFILING_UPLOAD_PERIOD65Profile upload interval in seconds
DD_PROFILING_HEAP_SAMPLING_INTERVALHeap sampling interval in bytes
DD_PROFILING_CODEHOTSPOTS_ENABLEDtrueLink profiles to traces (Code Hotspots)
DD_PROFILING_ENDPOINT_COLLECTION_ENABLEDtrueTag profiles with endpoint information
DD_PROFILING_TIMELINE_ENABLEDfalseEnable timeline view in profiles

Code Hotspots

When DD_PROFILING_CODEHOTSPOTS_ENABLED=true (the default), the profiler links profiling data to APM traces. In the Datadog trace view, you can drill into a span and see the flame graph for exactly that span, making it easy to identify which function inside a slow request is consuming the most time.

Serverless environments

On AWS Lambda (AWS_LAMBDA_FUNCTION_NAME is set), the profiler uses a ServerlessProfiler variant that adapts profile upload timing to the Lambda execution lifecycle. Enable it the same way:
DD_PROFILING_ENABLED=true
When running on Lambda, also set DD_TRACE_AGENT_URL to point to the Datadog Lambda Extension so that profiles are shipped during the Lambda execution lifecycle rather than after function return.

Performance overhead

The wall-time profiler uses V8’s sampling-based CPU profiler, which has very low overhead (typically under 1% CPU). Heap profiling has slightly higher overhead depending on allocation rate. For most production workloads, the combined overhead of both profile types is under 2–3%.

Build docs developers (and LLMs) love