Lesson 4.2:
Observability & Tracing
The Three Pillars
In a distributed world, simple console logs are not enough. Observability is built on three pillars: **Logs**, **Metrics**, and **Traces**.
Distributed Tracing (OpenTelemetry)
OpenTelemetry (OTel) is the industry standard for tracing requests across multiple services. By passing a trace ID, you can see the lifecycle of a request from the frontend to the database.
// Example: Context propagation in Node.js
import { trace } from '@opentelemetry/api';
const tracer = trace.getTracer('user-service');
const span = tracer.startSpan('db-query');
// ... logic ...
span.end();
Metrics & Alerting
Monitor the health of your services in real-time. Key metrics like CPU usage, error rates, and request latency (p99) allow you to detect problems before they impact users.
Check Your Knowledge
Which pillar allows you to follow a single request across multiple services?