20 · Production engineering and architecture / LESSON 98 OF 102
Logs, metrics, traces, and service objectives
Operational evidence should explain what failed, where time went, and who was affected without exposing secrets.
Before this lesson: Docker builds, networking, and persistent data
Understand the topic
Structured logs capture events; metrics aggregate measurements; traces connect spans across request boundaries. Use bounded metric labels such as route templates and status classes, not user IDs or raw URLs containing IDs.
Define an availability and latency objective for an actual user operation. Track p95 or p99 alongside request volume and error rate. Expose only intended actuator endpoints and restrict sensitive management access; health details can reveal internal dependencies.
EXAMPLE · PROPERTIES
application.properties
management.endpoints.web.exposure.include=health,info,prometheus
management.endpoint.health.show-details=never
management.endpoint.health.probes.enabled=trueWhat to expect
Prometheus exposure requires its Micrometer registry dependency. Apply an explicit management endpoint network and authentication policy before deployment.
YOUR TURN
Put it into practice
- 01Instrument task creation latency and error counts.
- 02Simulate a slow database locally and correlate logs, metrics, and request IDs.
- 03Verify: The runbook distinguishes application errors from dependency latency without logging tokens or personal request bodies.
Pass a quiz or complete a lab to check today’s streak. Each lesson counts once per day, including when you review it later.
UNDER THE HOOD
Build the mental model
Operational evidence should explain what failed, where time went, and who was affected without exposing secrets.
- 01Structured logs capture events; metrics aggregate measurements; traces connect spans across request boundaries. Use bounded metric labels such as route templates and status classes, not user IDs or raw URLs containing IDs.
- 02Define an availability and latency objective for an actual user operation. Track p95 or p99 alongside request volume and error rate. Expose only intended actuator endpoints and restrict sensitive management access; health details can reveal internal dependencies.
- 03Trace the example: Prometheus exposure requires its Micrometer registry dependency. Apply an explicit management endpoint network and authentication policy before deployment.
A mistake worth avoiding
Monitoring storage explodes after adding userId as a metric label.
DEBUGGING ROOM
Something broke. Where do you look?
Monitoring storage explodes after adding userId as a metric label.
Before revealing the diagnosis, write down your first investigation step.
CHECK YOUR UNDERSTANDING
Is a raw task ID a good general-purpose metric label?
BUILD IT YOURSELF
Instrument task creation latency and error counts.
- 1.Instrument task creation latency and error counts.
- 2.Simulate a slow database locally and correlate logs, metrics, and request IDs.
- 3.Reproduce this failure, then repair it: Monitoring storage explodes after adding userId as a metric label.
Acceptance checklist
Lab completion is your self-report. Knowledge checks do not certify project quality.
RETRIEVE IT FROM MEMORY
Is a raw task ID a good general-purpose metric label?
Revisit this lesson in three days after a successful check or lab.
Ready for the next step?
The runbook distinguishes application errors from dependency latency without logging tokens or personal request bodies.
Reading is separate from passing a knowledge check or completing a lab.