Stop 19 · Monitoring & LoggingTopics · 6/9

Application Performance Monitoring

Part of the Backend Developer Roadmap

In short

Users say 'the app is slow'. Slow where? APM tools time every request, database query and external call, so you see exactly which part is eating the seconds.

Tools (APM) that track your API's response times, throughput, and slow database queries in production, helping you find performance problems before users complain.

The purple blob jogs on a track while checking a fitness band that shows a heartbeat line.

Think of it like this

The runner's fitness band

A coach doesn't just say 'run faster'. The fitness band shows heart rate per lap, pace per kilometre and exactly where the runner slowed down. APM is that band for your API: timing for every request, broken into the steps inside it.

Watch it happen

One slow request, span by span

GET /cart
Auth 4 ms
SQL 820 ms
Redis 2 ms
Response

1/5A request to GET /cart starts a trace. Total time: 870 ms, way over a 200 ms target.

The big ideas

What you need to know

Traces and spans

A trace is one request's full story. Spans are the timed steps inside it: middleware, queries, HTTP calls.

Watch p95, not the average

Averages hide pain. p95 latency tells you how slow things are for the unluckiest 5 percent of requests.

Distributed tracing

Trace IDs travel in headers between services, so one trace can cover the API, the payment service and the queue worker.

OpenTelemetry

An open standard for traces and metrics. Instrument once and send the data to whichever APM tool you choose.

See it in code

Walk through the code

ts
1// instrumentation.ts, loaded before your app:2// node --import ./dist/instrumentation.js dist/server.js3import { NodeSDK } from "@opentelemetry/sdk-node";4import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";5import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";6 7const sdk = new NodeSDK({8  serviceName: "orders-api",9  traceExporter: new OTLPTraceExporter({10    url: "http://localhost:4318/v1/traces",11  }),12  instrumentations: [getNodeAutoInstrumentations()],13});14 15sdk.start();

1/4This file must load before Express and pg, so it can hook into them.

Auto-instrumentation creates spans for Express routes, pg queries, Redis and outgoing fetch calls without touching your route code.

Save yourself the pain

Common mistakes

Oops

Only looking at the average response time.

Do this instead

A fine-looking average can hide a few percent of users waiting seconds. Track p95 and p99.

Oops

Adding APM to one service but not the others.

Do this instead

Then each trace shows half a story. Instrument every service so trace context flows through automatically.

Your mission

Find your slowest span

~40 min

Quick check

Average latency looks fine but users still complain about slowness. Which number should you check?

Go deeper

  1. 1Set up a free-tier APM tool on a deployed project.
  2. 2Identify your slowest endpoint using APM data.
  3. 3Learn how APM traces a single request across multiple services/database calls.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge