Backend Observability: Logs, Metrics, and Traces
Monitoring tells you that a system is broken; observability tells you exactly why it is broken.
- Logs record discrete events. Structuring your logs as JSON allows centralized logging systems to query and filter them instantly based on user IDs or request paths.
- Metrics are aggregations of data over time. Tracking error rates, CPU usage, and request latency helps you build alerts before a system completely fails.
- Distributed Tracing assigns a unique ID to a request as it enters your system, passing that ID through every microservice it touches. This makes it trivial to find the exact database query slowing down an API endpoint.