What is OpenTelemetry and how is it used in Node.js?

Why Interviewers Ask This

This is a differentiating question used for senior and lead roles. Interviewers want to see if you can explain not just what happens, but why — and what the trade-offs are in different approaches.

Answer

OpenTelemetry (OTel) is an open-source observability framework providing APIs, SDKs, and tools for generating, collecting, and exporting telemetry data: traces (request flows across services), metrics (counters, histograms, gauges), and logs. It is vendor-neutral — export to Jaeger, Zipkin, Datadog, New Relic, or any OTel-compatible backend. Node.js setup: (1) Install: @opentelemetry/sdk-node, @opentelemetry/auto-instrumentations-node; (2) Initialize before loading app code: const sdk = new NodeSDK({ traceExporter: new OTLPTraceExporter(), instrumentations: [getNodeAutoInstrumentations()] }); sdk.start();; (3) Auto-instrumentation automatically instruments Express routes, HTTP calls, database queries (pg, mongodb, redis) without code changes. Traces show the full lifecycle of a request across services, including which function was slow. Metrics track request rates, error rates, and latency percentiles (p50, p95, p99). Baggage propagates key-value data (user ID, feature flags) alongside trace context. OTel is essential for debugging distributed systems and understanding production performance.

Common Mistake

Don't just define the term — demonstrate that you understand when to use it and when not to. Showing awareness of trade-offs is what separates average from strong Node.js candidates.