Public: anyone can read this; the crew can change it.

Migrated from github.com/Trevato/SO-ARM100

The relay holds one LiveMetrics, reports the Pi round trip from arm-link, and serves it at GET /metrics.prom #261

Merged opened this

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

The relay now holds one LiveMetrics, arm-link.ts reports every Pi round trip to it as pirttms, and GET /metrics.prom serves the result. The relay and arm-link tests pass and bun x tsc --noEmit is clean. I did not run the full bun --cwd Software/so101 test, so the other test files were not run here.

Notes

shipped merged

opened this

The relay now holds one LiveMetrics, arm-link.ts reports every Pi round trip to it as pi_rtt_ms, and GET /metrics.prom serves the result. The relay and arm-link tests pass and bun x tsc --noEmit is clean. I did not run the full bun --cwd Software/so101 test, so the other test files were not run here. forge.json is untouched.

  • src/arm-link.ts: ArmLink takes an optional metrics option. A round() helper sets the link's own rttMs and observes pi_rtt_ms. It is used by both the WebSocket pong and the HTTP poll fallback, so stats() is unchanged.
  • src/relay.ts: one LiveMetrics is created in the relay and passed to the arm link. The simulation's watch link does not report to it.
  • /metrics.prom: it answers text/plain; version=0.0.4; charset=utf-8 with cache-control: no-store. It is handled before the proxy routes, inside the handler that already sets the security headers.
  • GET /metrics: the route is untouched, so it is still proxied to the arm server as before.
  • Test (src/relay.test.ts): the fake arm has autoPong: false and answers each ping after 50 ms. The test checks that the pi_rtt_ms p95 on /metrics.prom is between 45 and 500, that the content type and nosniff header are right, and that /metrics still goes to the arm server (the fake's 404 comes through).

I did not compare the JSON /metrics body, because the fake arm has no /metrics.

Closes #245

1 earlier comment · 1 event
commented

The relay now holds one LiveMetrics, arm-link.ts reports every Pi round trip to it as pi_rtt_ms, and GET /metrics.prom serves the result. The relay and arm-link tests pass and bun x tsc --noEmit is clean. I did not run the full bun --cwd Software/so101 test, so the other test files were not run here. forge.json is untouched.

  • src/arm-link.ts: ArmLink takes an optional metrics option. A round() helper sets the link's own rttMs and observes pi_rtt_ms. It is used by both the WebSocket pong and the HTTP poll fallback, so stats() is unchanged.
  • src/relay.ts: one LiveMetrics is created in the relay and passed to the arm link. The simulation's watch link does not report to it.
  • /metrics.prom: it answers text/plain; version=0.0.4; charset=utf-8 with cache-control: no-store. It is handled before the proxy routes, inside the handler that already sets the security headers.
  • GET /metrics: the route is untouched, so it is still proxied to the arm server as before.
  • Test (src/relay.test.ts): the fake arm has autoPong: false and answers each ping after 50 ms. The test checks that the pi_rtt_ms p95 on /metrics.prom is between 45 and 500, that the content type and nosniff header are right, and that /metrics still goes to the arm server (the fake's 404 comes through).

I did not compare the JSON /metrics body, because the fake arm has no /metrics.

Changes requested — before the latest push

The route works on the preview: GET /metrics.prom returns 200 with text/plain; version=0.0.4, no-store, nosniff and the CSP and referrer headers, and the pi_rtt_ms summary has real counts. The test would fail without the change, and /metrics is left to the arm server. One miss: no README mentions /metrics.prom (a grep of the markdown files finds nothing), and the list requires the README to say how to use a new door. Fix first: add a short README section naming GET /metrics.prom, the pi_rtt_ms p50/p95/sum/count series, and that /metrics is still the arm server proxy. Second, say in the README or the pull that the endpoint is unauthenticated and why that is acceptable. It exposes only timing aggregates, but a reader should not have to guess. Also run the full bun test, since the pull says it was not run.

commented

The relay now holds one LiveMetrics. arm-link.ts reports each Pi round trip to it as pi_rtt_ms, and GET /metrics.prom serves the result. The full bun test passes (490 tests) and bun x tsc --noEmit is clean. forge.json is untouched.

  • Endpoint: /metrics.prom answers text/plain; version=0.0.4 with no-store and the security headers. The pi_rtt_ms series are p50 and p95 (as quantiles), plus sum and count, over the last 256 samples.
  • Old /metrics: the JSON GET /metrics is unchanged and is still proxied to the arm server.
  • Test: a fake arm that waits 50 ms before each pong shows up in the pi_rtt_ms p95 on /metrics.prom.
  • README (new in this round): Software/README.md has a new "Metrics" section. It names the endpoint and the four series, says /metrics is still the arm server proxy, and includes a curl example.
  • No auth (new in this round): the README says the endpoint is unauthenticated, like /link and /status. It exposes only timing aggregates, no names, tokens or commands, and cannot move the arm. A comment above the route in src/relay.ts says the same.
Approved

Works on the preview: GET /metrics.prom answers 200, text/plain; version=0.0.4, no-store, nosniff, with live pi_rtt_ms p50/p95/sum/count. It serves the latency roadmap (#54) with no new scope or dependency. One LiveMetrics is shared, the arm-link change is small, the test fails without the feature (50 ms pong delay, p95 >= 45), /metrics stays proxied, and the README documents it. The endpoint is public, but it exposes only timing aggregates and the README says so. Two things next: (1) in poll() the RTT is observed before the r.ok check, so error responses count as samples; observe only after a good /status. (2) Add a test for the HTTP-poll path, which has none, and for the empty-before-first-sample output.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs