Production observability

Observability: Logs, Metrics, and Traces

Instrument services with correlated events, time-series signals, and request traces that answer operational questions without leaking sensitive data.

How this page is maintained

Written for learners, checked against the sources below, and reviewed every quarter. Last reviewed July 27, 2026.

Short answer

Logs record discrete events, metrics summarize numeric behavior over time, and traces connect work across a request path. Useful observability starts from service questions and consistent context, then links telemetry with request identifiers, service names, versions, and environments while controlling volume, retention, and sensitive data.

Who this is for: Developers and operations teams building monitoring that supports incident detection, diagnosis, capacity planning, and release decisions.

  • Design telemetry from questions operators must answer, not from every value the system can emit.
  • Carry stable request and trace context across service boundaries so signals can be correlated.
  • Protect telemetry as production data through redaction, access limits, retention, and cost controls.

Give each signal a job

Metrics are efficient for rates, distributions, gauges, and alerts across many events. Logs preserve event details useful for debugging and audit, provided fields and severity are consistent. Traces represent spans of work and parent-child timing across services. None is automatically superior; they answer different questions and should point investigators toward one another.

Start with critical user journeys and service-level indicators. Ask how operators detect failure, locate the responsible component, distinguish release regressions, and estimate remaining capacity. Instrument those paths first. Collecting all debug output indefinitely creates expense and noise while making the decisive evidence harder to find.

Build structured, bounded telemetry

Use structured log fields for timestamp, severity, service, environment, version, event name, request identifier, and relevant safe dimensions. Keep messages understandable, but avoid parsing prose for core fields. Metrics need stable names, units, and labels. High-cardinality labels such as user or request IDs can overwhelm metric systems and belong in logs or traces instead.

Trace spans should describe meaningful operations, record status, and carry context through HTTP, messaging, and job boundaries. Sampling controls cost, but errors and rare paths may need preferential retention. Clock synchronization and consistent version labels matter when comparing events. Define schemas and ownership so every service does not invent conflicting fields.

Prevent sensitive and noisy output

Never log passwords, access tokens, session cookies, private keys, or full payment data. Review request and response logging because ordinary payloads may contain personal or confidential information. Redact near the source, use allowlists for captured fields, restrict telemetry access, and set retention according to operational and legal needs.

Control volume with severity standards, sampling, aggregation, and expiration. An exception should be logged once at the boundary that handles it rather than at every layer with the same stack trace. Rate-limit repetitive failures while preserving a counter. Monitor telemetry pipeline drops and delays so silence is not mistaken for health.

Connect dashboards, alerts, and investigation

Dashboards should show demand, errors, latency, saturation, deployment markers, and dependency health for one service or journey. Alerts need an actionable condition, owner, urgency, and runbook. Page on customer-impacting symptoms or imminent exhaustion; use lower-urgency channels for diagnostic signals that do not require immediate action.

Practice moving from an alert to a trace, from a slow span to related logs, and from an error event to aggregate metrics. During review, note missing context and confusing fields. Test observability during staged failure exercises and releases. A platform that cannot show whether a deployment helped or hurt is not ready for unattended automation.

Instrument a slow checkout path

Customers report intermittent slow checkout, but each service has separate text logs and no shared request identifier.

  1. Define checkout success, latency, and error indicators, then add environment and release labels to their metrics.
  2. Propagate trace context from the edge through cart, pricing, payment, and order services, including asynchronous messages.
  3. Emit structured safe logs with trace identifiers and operation names, excluding customer and payment secrets.
  4. Build a journey dashboard and test one controlled delay to verify the alert links to a trace and the trace links to the responsible logs.
Result: Operators can move from customer impact to the slow operation and its context without searching unrelated logs or exposing payment data.

Service telemetry contract

Use this contract to keep signals comparable and useful across services.

  • Service, environment, owner, version, critical journeys, and operational questions.
  • Metric name, type, unit, labels, cardinality budget, source, and alert relationship.
  • Log event, severity, structured fields, request context, redaction, and sampling rule.
  • Trace operation, propagation boundary, span attributes, error status, and retention sampling.
  • Dashboard, deployment marker, alert owner, runbook, access policy, cost budget, and pipeline-health check.

Common mistakes

  • Putting request IDs or customer emails into metric labels and creating unbounded cardinality.
  • Logging complete request bodies to make debugging easier without reviewing sensitive fields.
  • Paging on every internal error count without connecting the alert to user impact or an operator action.

Try one

A dashboard shows normal average latency while customers report severe intermittent delays. What telemetry changes would help reveal the problem?

A strong answer uses latency distributions or percentiles rather than averages, separates critical routes, and correlates outliers with traces, versions, zones, and dependency spans. It verifies sampling retains slow requests and checks telemetry loss. It avoids adding customer identifiers as metric labels and protects detailed logs through controlled access.

Sources

Learn this with a tutor

Tell LearnLive what you already know and what you need to do with logs, metrics, and traces.

Build this course