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

Migrated from github.com/Trevato/SO-ARM100

The app counts its own numbers: Pi round trip, camera fps in, viewers, frames dropped and bytes out, at /metrics.prom and a one-line log each minute #100

Closed opened this
Closed without merging

The relay now counts its own numbers, serves them at GET /metrics.prom, and logs a one-line summary to stdout every 60 seconds. I ran the type check and the live-metrics, relay, arm-link, camera-feed and cameras tests. They pass.

Notes

stopped closed without shipping deploy 45debd2

opened this

The relay now counts its own numbers, serves them at GET /metrics.prom, and logs a one-line summary to stdout every 60 seconds. I ran the type check and the live-metrics, relay, arm-link, camera-feed and cameras tests. They pass. I didn't run the whole suite; the forge does that on the push.

  • Counters: the new src/live-metrics.ts holds them. Hot paths only add to a number. The Pi round trip comes from the last 512 samples and p50/p95 are worked out when asked.
  • What it counts:

- The Pi round trip, p50 and p95. - Camera frames in, as a total and as frames per second over 10 s. - Connected viewers per kind: follow, live, machine, camera. - /follow commands received and dropped. - Bytes sent to viewers.

  • Bytes sent: this covers camera streams and the replies the arm sends back on /follow. The /live and /machine pushes aren't counted.
  • Hooks:

- ArmLink has a new onRtt option, called on each ping reply or polled GET. - FeedOptions gains onFrame and onBytes. - In relay.ts, each early return in the /follow message handler counts a drop. - Viewers are counted from the socket or response closing.

  • Endpoint: /metrics.prom answers text/plain; version=0.0.4. The existing JSON /metrics is untouched.
  • Log timer: summaryEveryMs is a new relay option, default 60 s. The timer is unref'd and cleared on close.
  • Tests:

- live-metrics.test.ts: injected delays show up in p95 (p50 stays put), the fps window ages out, and every Prometheus sample line parses as name, labels, value. - relay.test.ts: /metrics.prom is served over the real relay.

/metrics.prom needs no login, like the JSON /metrics.

🤖 Generated with Claude Code

Closes #88

commented

The relay now counts its own numbers, serves them at GET /metrics.prom, and logs a one-line summary to stdout every 60 seconds. I ran the type check and the live-metrics, relay, arm-link, camera-feed and cameras tests. They pass. I didn't run the whole suite; the forge does that on the push.

  • Counters: the new src/live-metrics.ts holds them. Hot paths only add to a number. The Pi round trip comes from the last 512 samples and p50/p95 are worked out when asked.
  • What it counts:

- The Pi round trip, p50 and p95. - Camera frames in, as a total and as frames per second over 10 s. - Connected viewers per kind: follow, live, machine, camera. - /follow commands received and dropped. - Bytes sent to viewers.

  • Bytes sent: this covers camera streams and the replies the arm sends back on /follow. The /live and /machine pushes aren't counted.
  • Hooks:

- ArmLink has a new onRtt option, called on each ping reply or polled GET. - FeedOptions gains onFrame and onBytes. - In relay.ts, each early return in the /follow message handler counts a drop. - Viewers are counted from the socket or response closing.

  • Endpoint: /metrics.prom answers text/plain; version=0.0.4. The existing JSON /metrics is untouched.
  • Log timer: summaryEveryMs is a new relay option, default 60 s. The timer is unref'd and cleared on close.
  • Tests:

- live-metrics.test.ts: injected delays show up in p95 (p50 stays put), the fps window ages out, and every Prometheus sample line parses as name, labels, value. - relay.test.ts: /metrics.prom is served over the real relay.

/metrics.prom needs no login, like the JSON /metrics.

🤖 Generated with Claude Code

commented

Declined: the failed check on #100 is not caused by this change, so I made no code change and pushed nothing. Run log: https://forge.open-platform.sh/trevato/arm/runs/01m5dx93qte79n8qxrtrtxajqb

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs