Structured logs, traces and application telemetry
Worked example
This is an offline lesson. Data are fictional and Docker commands are unexecuted. Any optional execution requires an authorized disposable VM, a verified context, synthetic data, restricted access and no external transmission. Do not collect secrets or private output. Before any authorized optional observation, verify the effective daemon endpoint including overrides, exact object ID and observation window. Bound collection time and output bytes; do not generate resource pressure or export private telemetry. Mark unavailable measurements NOT RUN.
Synthetic JSON lines (fictional identifiers, not actual OTLP):{"service":"api","request_id":"lab-7","route":"/items","status":503,"duration_ms":220}{"service":"catalog","request_id":"lab-7","event":"dependency_timeout","duration_ms":180}{"service":"api","request_id":"lab-8","route":"/items","status":200,"duration_ms":40}Example metric labels: service=api, route=/items, status_class=5xxDo not label metrics with request_id or raw user identifiers.Use a consistent schema, timestamp with timezone, service, severity, bounded route template and trace/span IDs when tracing is enabled. The two records with lab-7 are related, while lab-8 is a different request. This simplified request ID is not a valid distributed trace context by itself. OpenTelemetry instrumentation can propagate trace context, create spans and export signals through a configured collector; it does not automatically make Docker logs into traces. A metric label creates series combinations; unbounded request IDs cause cardinality growth. Use a route template rather than a unique URL and keep correlation IDs in appropriately protected logs/traces. Apply an allowlist and redaction before emission; do not log authentication headers, session tokens or raw payloads. Validate sampling, delivery failures and access controls before using telemetry in production. The three fictional records omit timestamps for brevity; a real schema requires them and a consistent clock. A shared request ID is not a trace or proof of causation. Validate bounded label values as well as label names, and distinguish an absent sampled span from an operation that never happened.
Common mistake
A matching request ID is a correlation clue, not proof of the root cause. Putting request IDs in metric labels is not an efficient way to search requests.
Manual practice
Group the three records by request_id, name the affected dependency hypothesis and choose three safe low-cardinality metric labels. Explain where to keep individual correlation IDs.
Worksheet: lab-fixtures/docker-observability/06-telemetry/scenario.txt.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Structured logs, traces and application telemetry — Knowledge check
Interpret synthetic observability evidence and choose safe diagnostic actions.
Which records belong to the same fictional request?
Which label is suitable for bounded HTTP metric series?
What does trace context propagation enable?