All posts
DevOps

Observability: Logs, Metrics, and Traces

9 min read

When production breaks at 2am, the only thing that matters is how fast you can see what is wrong. Observability is the difference between a five-minute fix and a two-hour guessing game. Build it before you need it.

The Three Pillars

Observability rests on three complementary signals. Each answers a different question.

Logs

Logs tell you what happened. Make them structured JSON, not free text, so you can filter and aggregate. Attach a request ID to every line so you can reconstruct a single request across services.

Metrics

Metrics tell you how much and how often: request rate, error rate, latency percentiles, queue depth. They are cheap to store and perfect for dashboards and alerts.

Traces

Traces tell you where the time went. A distributed trace follows one request through controllers, queries, and external calls, showing you the slow span instead of making you guess.

Instrumenting Laravel

The framework gives you hooks for all three.

Correlation IDs

Generate a request ID in middleware and push it into the log context. Every log line for that request now shares an ID, which turns log spelunking into a single filter.

Meaningful Metrics

Track the percentiles that reflect user experience. An average latency hides the slow tail; p95 and p99 are where your unhappy users live.

Alerting

Signals are useless if nobody looks at them until a customer complains.

Alert on Symptoms

Page on user-facing symptoms such as elevated error rate or p95 latency, not on causes like high CPU. Tie every alert to a runbook so the responder knows the first move.

Closing Thoughts

Logs, metrics, and traces each answer a question you will urgently need answered under pressure. Wire them in early, keep them structured, and alert on what users feel. Future-you, half asleep, will be grateful.