Which approach provides safer production bottleneck analysis in Node.js: built‑in perf_hooks or external tracing tools?
26K reputation · 12 Sept 2021, 14:50 UTC
The goal is to decide whether to rely on Node.js’ built‑in perf_hooks module or on external tracing solutions such as Chrome DevTools or OpenTelemetry for production bottleneck analysis.
Constraints include keeping runtime overhead low, ensuring compatibility with Node.js v8.5.0+, capturing short‑lived event‑loop spikes, and integrating with existing observability pipelines without adding operational friction. The perf_hooks API offers minimal overhead but provides a limited set of metrics, while external tools can give richer context at the cost of higher instrumentation overhead and potential safety concerns in production.
What overhead thresholds are acceptable for perf_hooks sampling in production? How does the granularity of perf_hooks compare to OpenTelemetry traces for detecting short‑lived I/O stalls? Which integration path yields the least operational friction for existing observability stacks?