Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
workbenchthis machine
/admin/data's Health section charts Pi temperature, with under-voltage minutes marked on the same axis #558
Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.
smith/arm:smith/546-admin-data-s-health-section-charts-pi-te → main 2 commits fork 2 threads · 2 unresolved
6 files
changed +70
−4
Software/so101/README.md +2 −2
| @@ -79,7 +79,7 @@ The relay (`src/relay.ts`, through `src/facts.ts`) keeps 90 days of what happene | ||
| 79 | 79 | - `compare=1`: adds `previous`, the same length of time just before, on the same steps (`compare=0` is the default). |
| 80 | 80 | - `turn=<id>`: instead of a range, one turn: `{ turn, events, samples }` from a minute before to a minute after, with the arm's events only (STOP, jam, block, reconnect, app start) and no one named. An unknown id is 404. |
| 81 | 81 | |
| 82 | A bad parameter is a 400 whose `error` says what to send; POST is 405. Shape of a range answer (trimmed): `{ from, to, step, t: [step starts], overview: { visitors, sessions, drivers, minutes, snapBacksPer100, arriveP95Ms, jams, uptime }, series: { sessions: [..], snapBacksPer100: [..], watchers: [..], uptime: [..], ... one array per step }, funnel, turnLengths, arrive: { edgesMs, counts }, reasons, versions, worst: [{ id, start, seconds, ended, releases, snapBacks, snapBacksPer100, jams, arriveP95Ms, commit }] (the ten measured turns with the most snap-backs per 100 releases, then the slowest arrive), live: { watchers, driving, queue }, oldest, commit, previous? }`. | |
| 82 | A bad parameter is a 400 whose `error` says what to send; POST is 405. Shape of a range answer (trimmed): `{ from, to, step, t: [step starts], overview: { visitors, sessions, drivers, minutes, snapBacksPer100, arriveP95Ms, jams, uptime }, series: { sessions: [..], snapBacksPer100: [..], watchers: [..], uptime: [..], piTempC: [..] (hottest Pi °C, null with no reading), undervoltMinutes: [..], ... one array per step }, funnel, turnLengths, arrive: { edgesMs, counts }, reasons, versions, worst: [{ id, start, seconds, ended, releases, snapBacks, snapBacksPer100, jams, arriveP95Ms, commit }] (the ten measured turns with the most snap-backs per 100 releases, then the slowest arrive), live: { watchers, driving, queue }, oldest, commit, previous? }`. | |
| 83 | 83 | |
| 84 | 84 | ## The Data view: /admin/data |
| 85 | 85 | |
| @@ -89,7 +89,7 @@ A bad parameter is a 400 whose `error` says what to send; POST is 405. Shape of | ||
| 89 | 89 | - **Precision**: snap-backs by cause (stacked), snap-backs per 100 releases, and the worst sessions; a session opens its numbers, its events (STOP, jam, block, reconnect, app start) on a timeline a minute either side, and the room each minute. |
| 90 | 90 | - **Latency**: p95 time to arrive over time, and the turns by their p95 arrive. |
| 91 | 91 | - **People**: in the room (watchers, driving, in line), visitors anonymous against account, where people drop off, wait in line, turn length, how turns ended, chat volume. |
| 92 | - **Health**: arm-link uptime; reconnects, app starts, STOPs, jams and blocks; camera fps. | |
| 92 | - **Health**: arm-link uptime; reconnects, app starts, STOPs, jams and blocks; Pi temperature with under-voltage minutes marked (the line is the hottest minute of each step, a block on the baseline is a step with under-voltage minutes, exact values on hover or tap); camera fps. | |
| 93 | 93 | |
| 94 | 94 | Choose Hour, Day, Week or All; drag across any chart to zoom every chart into that stretch (Reset zoom goes back); tick "Compare to the period before" for a faint line of the span just before and a change on each card; hover, tap, or focus a chart and use the arrow keys (Home, End) for exact values. Dashed upright lines on every time axis mark the app starting on a new commit. One column on a portrait phone, two in landscape and on a tablet, three from 1280 px wide; both colour schemes; the only motion is a fade and smooth scrolling, and only under `prefers-reduced-motion: no-preference`. |
| 95 | 95 |
Software/so101/src/data-page.ts +1
| @@ -169,6 +169,7 @@ export function renderDataPage(): string { | ||
| 169 | 169 | <section class="panel" aria-labelledby="h-chat"><h2 id="h-chat">People · chat volume</h2>${plot("c-chat")}</section> |
| 170 | 170 | <section class="panel" aria-labelledby="h-uptime"><h2 id="h-uptime">Health · arm link uptime</h2>${plot("c-uptime")}</section> |
| 171 | 171 | <section class="panel" aria-labelledby="h-events"><h2 id="h-events">Health · reconnects, starts, STOPs, jams</h2><p class="note" id="starts"></p>${plot("c-events")}</section> |
| 172 | <section class="panel" aria-labelledby="h-pi"><h2 id="h-pi">Health · Pi temperature, under-voltage minutes</h2><p class="note">The line is the hottest minute of each step; a block on the baseline is a step with minutes under-voltage.</p>${plot("c-pi")}</section> | |
| 172 | 173 | <section class="panel" aria-labelledby="h-fps"><h2 id="h-fps">Health · camera fps</h2>${plot("c-fps")}</section> |
| 173 | 174 | </div> |
| 174 | 175 | </main> |
Software/so101/src/data-series.test.ts +8
| @@ -132,3 +132,11 @@ describe("parseRange", () => { | ||
| 132 | 132 | expect(p(`from=${now - H}&to=${now}&step=300`)).toEqual({ from: now - H, to: now, step: 300 }); |
| 133 | 133 | }); |
| 134 | 134 | }); |
| 135 | ||
| 136 | describe("Pi health series", () => { | |
| 137 | test("a step carries its hottest temperature and its under-voltage minutes; no readings are null and zero", () => { | |
| 138 | const a = aggregate(input({ samples: [sample(T0 + 1000, { piTemp: 51.24, piUndervolt: false }), sample(T0 + 61_000, { piTemp: 58.06, piUndervolt: true }), sample(T0 + 121_000, { piUndervolt: true }), sample(T0 + H + 1000)] })); | |
| 139 | expect(a.series.piTempC).toEqual([58.1, null, null, null]); | |
| 140 | expect(a.series.undervoltMinutes).toEqual([2, 0, 0, 0]); | |
| 141 | }); | |
| 142 | }); |
Software/so101/src/data-series.ts +11
| @@ -10,6 +10,7 @@ | ||
| 10 | 10 | * - watchers, drivers now, queue: the minute samples; a step shows the most seen. Camera fps: their mean. |
| 11 | 11 | * - uptime: the minutes the arm link was sampled live over the minutes that have passed since the range (or the |
| 12 | 12 | * record) began, in a step and in all. |
| 13 | * - Pi temperature: the hottest minute sample of a step; under-voltage minutes: the samples that said the Pi was under-voltage. | |
| 13 | 14 | * - counts of chat, STOP, jam, block and reconnect events are what happened in the step, nothing smoothed. |
| 14 | 15 | * - the worst sessions: the turns the arm measured, most snap-backs per 100 releases first, then the slowest p95 arrive. |
| 15 | 16 | */ |
| @@ -94,6 +95,10 @@ export interface Series { | ||
| 94 | 95 | restarts: number[]; |
| 95 | 96 | uptime: Array<number | null>; |
| 96 | 97 | fps: Record<string, Array<number | null>>; |
| 98 | /** The hottest Pi reading in the step, °C. */ | |
| 99 | piTempC: Array<number | null>; | |
| 100 | /** Minutes sampled under-voltage in the step. */ | |
| 101 | undervoltMinutes: number[]; | |
| 97 | 102 | } |
| 98 | 103 | |
| 99 | 104 | export interface Marker { |
| @@ -229,6 +234,8 @@ export function aggregate(input: Input): Aggregate { | ||
| 229 | 234 | const live = zeros(); |
| 230 | 235 | const sampledLink = zeros(); |
| 231 | 236 | const fpsOf: Record<string, number[][]> = {}; |
| 237 | const piTemps = lists(); | |
| 238 | const undervolt = zeros(); | |
| 232 | 239 | for (const s of input.samples) { |
| 233 | 240 | const i = at(s.at); |
| 234 | 241 | sampled.watchers[i]!.push(s.watchers); |
| @@ -236,6 +243,8 @@ export function aggregate(input: Input): Aggregate { | ||
| 236 | 243 | sampled.queue[i]!.push(s.queue); |
| 237 | 244 | sampledLink[i]!++; |
| 238 | 245 | if (s.linkLive) live[i]!++; |
| 246 | if (s.piTemp !== undefined) piTemps[i]!.push(s.piTemp); | |
| 247 | if (s.piUndervolt) undervolt[i]!++; | |
| 239 | 248 | for (const [camera, v] of Object.entries(s.fps)) (fpsOf[camera] ??= lists())[i]!.push(v); |
| 240 | 249 | } |
| 241 | 250 | const peak = (l: number[][]) => l.map((v) => (v.length ? Math.max(...v) : null)); |
| @@ -286,6 +295,8 @@ export function aggregate(input: Input): Aggregate { | ||
| 286 | 295 | reconnects: count.reconnect, |
| 287 | 296 | restarts: count["app start"], |
| 288 | 297 | uptime, |
| 298 | piTempC: peak(piTemps).map((v) => round(v)), | |
| 299 | undervoltMinutes: undervolt, | |
| 289 | 300 | fps: Object.fromEntries(Object.entries(fpsOf).map(([camera, l]) => [camera, l.map((v) => round(mean(v)))])), |
| 290 | 301 | }, |
| 291 | 302 | funnel: { |
Software/so101/src/data-view.test.ts +34 −1
| @@ -122,7 +122,7 @@ test("the script draws every chart from a real answer, opens a worst session, an | ||
| 122 | 122 | const snapshot = { driver: null, queue: [] } as never; |
| 123 | 123 | facts.event("app start"); |
| 124 | 124 | facts.visit("browser-1"); |
| 125 | facts.sample({ watchers: 2, drivers: 1, queue: 0, linkLive: true, fps: { "1": 24 } }); | |
| 125 | facts.sample({ watchers: 2, drivers: 1, queue: 0, linkLive: true, fps: { "1": 24 }, piTemp: 61.5, piUndervolt: true }); | |
| 126 | 126 | facts.turn({ kind: "turn", ended: null, started: ada }, snapshot); |
| 127 | 127 | facts.event("jam"); |
| 128 | 128 | const id = facts.turn({ kind: "turn", ended: { who: ada, reason: "taken over by the owner" }, started: null }, snapshot)!; |
| @@ -151,6 +151,12 @@ test("the script draws every chart from a real answer, opens a worst session, an | ||
| 151 | 151 | const causes = byId.get("c-causes")!; |
| 152 | 152 | expect(causes.all((n) => n.classes.has("version")).length).toBe(1); |
| 153 | 153 | expect(causes.all((n) => n.classes.has("vlabel"))[0]!.textContent).toBe("abc1234"); |
| 154 | // the Pi chart marks under-voltage minutes on the temperature axis, and a tap gives both exact values | |
| 155 | const pi = byId.get("c-pi")!; | |
| 156 | expect(pi.all((n) => n.classes.has("mark")).length).toBe(1); | |
| 157 | expect(pi.all((n) => n.classes.has("none"))).toHaveLength(0); | |
| 158 | pi.children[0]!.children[0]!.fire("pointerdown", { clientX: 590, buttons: 1 }); | |
| 159 | expect(pi.all((n) => n.classes.has("tip"))[0]!.textContent).toMatch(/hottest.*under-voltage/); | |
| 154 | 160 | // the worst session is listed, and opens its numbers and events |
outdated
This asserts that c-fps has no 'none' text, but it has data, so it does not test the empty message. Replace it with a Pi chart that has only under-voltage minutes (marks drawn, no 'none' text) and one that has no readings at all (the empty text shows). |
||
| 155 | 161 | expect(tbody.children).toHaveLength(1); |
| 156 | 162 | expect(tbody.textContent).toContain("2 / 8"); |
| @@ -207,3 +213,30 @@ test("the script draws every chart from a real answer, opens a worst session, an | ||
| 207 | 213 | expect(ranges.map((r) => r.attrs["aria-pressed"])).toEqual(["true", "false", "false", "false"]); |
| 208 | 214 | expect(byId.get("status")!.textContent).toBe(""); |
| 209 | 215 | }); |
| 216 | ||
| 217 | /** The Pi chart after the script ran on a record holding one sample (or none). */ | |
| 218 | async function piChart(sample?: { piTemp?: number; piUndervolt?: boolean }): Promise<Node> { | |
| 219 | dir = mkdtempSync(join(tmpdir(), "so101-data-view-")); | |
| 220 | const facts = new Facts({ file: join(dir, "facts.sqlite"), commit: "abc1234def56" }); | |
| 221 | lobby = new Lobby({ identityKey: KEY, adminFile: join(dir, "admin.json"), countsFile: join(dir, "visitors.json") }); | |
| 222 | relay = await startRelay({ port: 0, simulation: "http://127.0.0.1:1", lobby, facts }); | |
| 223 | const base = `http://127.0.0.1:${relay.port}`; | |
| 224 | if (sample) facts.sample({ watchers: 0, drivers: 0, queue: 0, linkLive: true, fps: {}, ...sample }); | |
| 225 | const { document, byId } = dom(); | |
| 226 | new Function("document", "fetch", "addEventListener", "setTimeout", "clearTimeout", DATA_SCRIPT)(document, (url: string) => fetch(base + url, { headers: owner }), () => {}, () => 0, () => {}); | |
| 227 | await settle(); | |
| 228 | return byId.get("c-pi")!; | |
| 229 | } | |
| 230 | ||
| 231 | test("the Pi chart draws under-voltage minutes even with no temperature, and says so only when it has neither", async () => { | |
| 232 | const only = await piChart({ piUndervolt: true }); | |
| 233 | expect(only.all((n) => n.classes.has("mark")).length).toBe(1); | |
| 234 | expect(only.all((n) => n.classes.has("none"))).toHaveLength(0); | |
| 235 | await relay?.close(); | |
| 236 | lobby?.close(); | |
| 237 | rmSync(dir, { recursive: true, force: true }); | |
| 238 | ||
| 239 | const neither = await piChart(); | |
| 240 | expect(neither.all((n) => n.classes.has("mark"))).toHaveLength(0); | |
| 241 | expect(neither.all((n) => n.classes.has("none"))[0]!.textContent).toContain("No Pi temperature or under-voltage reading"); | |
| 242 | }); |
Software/so101/src/ui/data-view.js +14 −1
| @@ -124,6 +124,12 @@ | ||
| 124 | 124 | const lone = s.values.map((v, i) => (finite(v) && !finite(s.values[i - 1]) && !finite(s.values[i + 1]) ? i : -1)).filter((i) => i >= 0); |
| 125 | 125 | if (!s.prev) for (const i of lone) svg("circle", { cx: x(i), cy: y(s.values[i]), r: 2.5, class: `dot c${s.color}` }, root); |
| 126 | 126 | } |
| 127 | // marks on the same axis: a tick on the baseline wherever the step has a count | |
| 128 | for (const m of spec.marks || []) { | |
| 129 | m.values.forEach((v, i) => { | |
| 130 | if (finite(v) && v > 0) svg("rect", { x: L + i * bw + bw * 0.11, y: y(0) - 7, width: Math.max(2, bw * 0.78), height: 7, class: `fill mark c${m.color}` }, root); | |
| 131 | }); | |
| 132 | } | |
| 127 | 133 | // the deployed commits |
| 128 | 134 | for (const v of d.versions) { |
| 129 | 135 | if (v.at < d.from || v.at >= d.to) continue; |
| @@ -132,7 +138,7 @@ | ||
| 132 | 138 | svg("title", {}, mark).textContent = `deployed ${v.commit} at ${new Date(v.at).toLocaleString()}`; |
| 133 | 139 | svg("text", { x: vx + 3, y: T - 4, class: "vlabel" }, root).textContent = v.commit.slice(0, 7); |
| 134 | 140 | } |
| 135 | if (!spec.series.some((s) => !s.prev && s.values.some((v) => finite(v) && v !== 0))) svg("text", { x: W / 2, y: H / 2, class: "none", "text-anchor": "middle" }, root).textContent = spec.empty || "Nothing in this range"; | |
| 141 | if (!spec.series.concat(spec.marks || []).some((s) => !s.prev && s.values.some((v) => finite(v) && v !== 0))) svg("text", { x: W / 2, y: H / 2, class: "none", "text-anchor": "middle" }, root).textContent = spec.empty || "Nothing in this range"; | |
| 136 | 142 | // hover, tap, arrow keys: exact values; drag: zoom |
| 137 | 143 | const cursor = svg("line", { y1: T, y2: H - B, class: "cursor", visibility: "hidden" }, root); |
| 138 | 144 | const brush = svg("rect", { y: T, height: H - T - B, class: "brush", visibility: "hidden" }, root); |
| @@ -153,6 +159,12 @@ | ||
| 153 | 159 | row.append(`${s.prev ? "before: " : ""}${s.name} `); |
| 154 | 160 | html("b", null, spec.percent ? pct(s.values[at]) : fmt(s.values[at], s.unit), row); |
| 155 | 161 | } |
| 162 | for (const m of spec.marks || []) { | |
| 163 | const row = html("span", `row c${m.color}`, null, tip); | |
| 164 | html("i", null, null, row); | |
| 165 | row.append(`${m.name} `); | |
| 166 | html("b", null, fmt(m.values[at], m.unit), row); | |
| 167 | } | |
| 156 | 168 | tip.hidden = false; |
| 157 | 169 | tip.classList.toggle("left", at > n / 2); |
| 158 | 170 | }; |
| @@ -345,6 +357,7 @@ | ||
| 345 | 357 | const s = d.series; |
| 346 | 358 | timeChart($("#c-uptime"), { label: "Arm link uptime", percent: true, min: 1, series: [{ name: "live", values: s.uptime, color: 1, kind: "line" }], empty: "No link samples: the app is simulating, or just started" }); |
| 347 | 359 | timeChart($("#c-events"), { label: "Reconnects, app starts, STOPs, jams and blocks", series: [{ name: "reconnects", values: s.reconnects, color: 2, kind: "bar" }, { name: "app starts", values: s.restarts, color: 4, kind: "bar" }, { name: "STOP", values: s.stops, color: 6, kind: "bar" }, { name: "jams", values: s.jams, color: 3, kind: "bar" }, { name: "blocks", values: s.blocks, color: 5, kind: "bar" }], empty: "No reconnect, app start, STOP, jam or block" }); |
| 360 | timeChart($("#c-pi"), { label: "Pi temperature and under-voltage minutes", series: [{ name: "hottest", values: s.piTempC, color: 3, kind: "line", unit: "°C" }], marks: [{ name: "under-voltage", values: s.undervoltMinutes, color: 4, unit: "min" }], empty: "No Pi temperature or under-voltage reading in this range" }); | |
| 348 | 361 | const cams = Object.keys(s.fps); |
| 349 | 362 | timeChart($("#c-fps"), { label: "Camera fps", series: cams.map((c, i) => ({ name: `camera ${c}`, values: s.fps[c], color: i % 8, kind: "line", unit: "fps" })), empty: "No H.264 camera reported fps" }); |
| 350 | 363 | const starts = sum(s.restarts); |
new above
offline
The new panel is not described in README.md's Health bullet. Add it there.