Node.js › Logging & Monitoring

What is an APM (Application Performance Monitoring) tool, and what capabilities does it typically add beyond basic logging?

Intermediate

Answer

An APM tool (like New Relic, Datadog APM, or Dynatrace) automatically instruments an application to capture detailed performance data -- transaction traces showing exactly where time is spent within a request (including database query timing and external API call timing), error tracking with full stack traces and grouping of similar errors, and real-time dashboards of throughput, latency percentiles, and error rates -- generally requiring far less manual instrumentation effort than building equivalent visibility purely from custom logs and metrics.
// Typical APM setup: install and initialize the agent, often at the very top of the entry file
require('newrelic'); // must be required before any other module in many APM tools

const express = require('express');
const app = express();
// The APM agent automatically instruments Express routes, database calls, etc.
Real-world example A team investigating a vague customer complaint of 'the app feels slow sometimes' installs an APM tool, which within a day surfaces a clear pattern: a specific database query used on one particular page consistently takes 2-3 seconds during peak hours, pinpointing exactly where to focus their optimization effort without needing to add any custom instrumentation themselves.

Common follow-ups: What's the performance overhead of running an APM agent's automatic instrumentation in production?;How do APM tools typically handle the cost tradeoff of capturing full trace data for every single request versus a sampled subset?