Page 6 of 8~112 min topic

Cost optimization lab

Add observability and tests

Metrics for usd_per_successful_answer and groundedness must distinguish bad input from component failure for finance partner capping July LLM spend at $12k.

~14 min this pageObservability

1Learn the idea

Read

Golden signals for this system

Instrument token+router cost controller for mixed FAQ vs complex research traffic so finance partner capping July LLM spend at $12k can answer: demand, errors, latency/age, saturation. Emit fields needed by usd_per_successful_answer and groundedness with bounded labels. Sample successful high-volume traces; keep errors and rollout transitions denser within policy.

Read

Alert path worth paging

Define at least one alert that would fire for COST-ROUTER-MISCLASS-14, with a for/pending window that survives deploy blips. Missing scrape or missing revision labels must not look like health. Include a trace/log example id format you will actually search.

Read

Implementation artifact

emit("llm_usd_total", value=usd, model=model, class_=class_)

Read

Tests for telemetry

Add a unit/integration check that metrics increment on the happy path and on the router sends long research prompts to mini — quality collapses, retries inflate spend branch. Store machine-readable output in CI artifacts when practical.

Read

Stage depth

Cardinality discipline: tenant and revision are usually enough; raw question text is not a label. Exemplars or trace links beat screenshots alone when debugging COST-ROUTER-MISCLASS-14. Define who owns alert fatigue review. If you export to a vendor, record retention and access. Synthetic probes should use non-sensitive fixtures and still exercise POST /v1/answer. Practice the query you will type at 2am once, while calm.

Read

Field notes for `cost-optimization-lab` / `observability`

Document the exact PromQL or log query in the runbook stub for this service. Verify histograms have buckets around your SLO target. Add a canary synthetic check that exercises the oracle path every few minutes in staging. Confirm that PII redaction happens before export. Track build/version as a label on the golden signals. Delete noisy debug logs before they become accidental product dependencies. In this chapter the product is token+router cost controller for mixed FAQ vs complex research traffic, the human stakeholder is finance partner capping July LLM spend at $12k, and the incident id you design against is COST-ROUTER-MISCLASS-14. Re-state the oracle in your notes — replay day shows −32% $ with groundedness drop ≤ 0.01 vs all-frontier baseline — and keep the invariant visible: simple FAQs route to mini model; monthly forecast alerts at 80% budget. Track usd_per_successful_answer and groundedness as the scoreboard. Surface under change control: POST /v1/answer. If you only have forty minutes, finish the fixture for router sends long research prompts to mini — quality collapses, retries inflate spend before polishing UI. Promotion language stays ternary: promote, hold, or roll back based on evidence, not hope.

Read

Extra rehearsal for Cost optimization lab (observability)

Set a timer for twelve minutes and attempt only the observability concerns for Cost optimization lab. Speak aloud what finance partner capping July LLM spend at $12k would see on success versus on router sends long research prompts to mini — quality collapses, retries inflate spend. Write three bullet artifacts you must keep: a fixture name tied to COST-ROUTER-MISCLASS-14, a metric query for usd_per_successful_answer and groundedness, and the rollback or refuse command for POST /v1/answer. Then extend the notes with one sentence on how simple FAQs route to mini model; monthly forecast alerts at 80% budget would be violated if you skipped this page. Close by restating the oracle in your own words without looking: replay day shows −32% $ with groundedness drop ≤ 0.01 vs all-frontier baseline.

Go deeper

Before you start

Why this matters

Name the dashboard row or log line finance partner capping July LLM spend at $12k opens first during COST-ROUTER-MISCLASS-14. It must include a correlation id and a bounded label from usd_per_successful_answer and groundedness. If telemetry is missing, write whether you promote, hold, or roll back — and why hold is the default.

In the wild

See how this idea shows up as a product and a company — then come back to the lesson. Skills transfer across vendors.

Check your understanding

Page assessment

Answer from memory. Completion is saved from this evidence, not from opening the next page.

1. Can you jump from alert to COST-ROUTER-MISCLASS-14-class evidence?
2. Do labels stay low-cardinality?
3. Is missing telemetry treated as hold?

All responses are required.