# Request Tracing Lab

By Chason Arthur
Revision 151.032
Published/updated 2026-11-04

## Start without installing dependencies

Extract this complete ZIP into a new folder. With Python 3 installed, run `python preview.py` from the extracted root. Open http://127.0.0.1:4210/. Stop with Ctrl+C. The prebuilt site is self-contained and makes no automatic external requests. Written reference links are optional. Do not open the files directly with file:// because workers and Wasm need HTTP.

## Run the native exercise

```sh
npm ci
npm test
node src/observability/server.mjs
```

The local service listens on 127.0.0.1:4201. Request /report eight times, then inspect /metrics and /traces. Stop it before the optional container exercise. From src/observability run docker compose up --build; visit http://127.0.0.1:3007/d/zyel-latency-lab/ and http://127.0.0.1:9097/. Generate requests to /report to populate the dashboard; rate queries need multiple scrapes. All exposed ports bind to loopback. Grafana’s public fake local administrator is labadmin / PUBLIC-LOCAL-LAB-ONLY; the dashboard is readable anonymously. Run docker compose down to discard containers. The recipe is pinned by image digest and was not executed during authoring because Docker was unavailable.

## Expected result

Both versions return eight successful responses. The safeguarded trace contains the request, service and database spans under one trace ID. A long tail remains visible even though availability is 100%.

## Scope

The worker creates real OpenTelemetry spans around actual timer waits. The database is a timed fixture. Eight requests teach latency arithmetic, not a production SLO window. A local HTTP service and optional Prometheus/Grafana recipe accompany the download.

## Change and rebuild

Node/browser packages: `npm ci`, `npm run rebuild`, then `python preview.py`. Go: edit src/go, run its tests and `python rebuild_wasm.py` before refreshing source. Python: edit src/python/engine.py and run `python refresh_source.py`. Rebuild keeps the local preview and source viewer aligned. FILE_MANIFEST.json describes the initial extracted package, not later edits. The source-map and source viewer manifest record the exact teaching files. Update edition/date metadata before publishing an edited version.

## Extension

Add a second concurrent dependency and show why child durations cannot simply be summed to explain total latency. Then define an eligible-event rule and test an alert against low-traffic and no-traffic periods.

Original teaching code and lessons are MIT-licensed. See THIRD_PARTY_NOTICES.md and licenses/. The package starts no production API, model, payment, email or cloud service.
