PeaBox Lab › PeaLang › Learn › Chapter 21 › Lesson 3

Part IV — Expert Production Engineering · Chapter 21 · Lesson 3 of 6 · 2 min read

Lesson 3: Liveness, Readiness, Metrics, Tracing, and Audit Retention

Lesson level: Expert

Purpose: Expose trustworthy health signals and retain useful evidence without disclosing data.

Learning Objectives

3.1 Concepts

create_serving_app exposes /live, /ready, /metrics, and /predict. In the base implementation /live reports live and /ready returns the loaded version names; neither proves dependencies, governance admission, or a sample prediction are healthy. ResilientRuntime.health reports a degraded state after a timeout, but the base readiness route does not consult it. Add the application readiness policy deliberately rather than treating a successful HTTP probe as end-to-end service health.

3.2 Annotated Example

The shipped metrics include request and error totals, average prediction latency, and uptime. Requests rejected before the prediction try block are not fully represented by those counters. SQLiteAuditStore records version, input hash, predictions, timestamp, and latency for successful predictions. Predictions themselves can be sensitive: hashing inputs does not make the audit store anonymous. TraceHooks supplies start/end callbacks; exporting traces is an additional integration.

3.3 Guided Practice

Classify a live process with no approved model, a healthy model with failed audit storage, and a transient downstream outage. Decide which condition removes traffic and which merits investigation without restarting the process.

3.4 Common Mistakes

Avoid liveness checks that depend on fragile remote services, high-cardinality customer labels, unrestricted metrics exposure, and retention values mistaken for automatic cleanup schedules.

3.5 Hands-On Lab

Deliverable: Configuration, fixtures, observed results, and a control-coverage table. Pass only when every expected acceptance or rejection is demonstrated.

3.6 Review Questions

Why can /ready return success while the service is unusable? Which failures escape the base counters? Who schedules and verifies audit pruning?

3.7 Applied Challenge

Write a health decision table and retention policy with access control, legal-hold handling, backup coverage, and tested cleanup. Treat operational choices as application policy, not RC2 defaults.

Lesson Summary

Health, metrics, traces, and audits answer different questions. Make their coverage, data sensitivity, storage dependencies, and lifecycle explicit.

Lesson status: Draft complete; ready for review. Source-checked, not execution-validated.

← Previous Next →