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

Migrated from github.com/Trevato/SO-ARM100

/metrics.prom counts camera frames in, bytes out and viewers per socket kind #273

Merged opened this

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

Merged

/metrics.prom now reports camera frames in, camera bytes out and a gauge of open sockets per kind. bun test in Software/so101 passes (515 tests), but bun x tsc --noEmit does not pass. It reports src/lobby.ts(357,80): 'span' is possibly 'undefined'.

Notes

shipped merged

opened this

/metrics.prom now reports camera frames in, camera bytes out and a gauge of open sockets per kind. bun test in Software/so101 passes (515 tests), but bun x tsc --noEmit does not pass. It reports src/lobby.ts(357,80): 'span' is possibly 'undefined'. That file is untouched here, and the same error shows up with my changes stashed, so I left it alone.

  • Counters: CameraFeed takes an optional metrics in its options. It counts camera_frames_in once per whole part from the source. It counts camera_bytes_out for every byte written to an MJPEG viewer and for each frame sent to a WebSocket sink. The relay passes its LiveMetrics into the feeds it builds, so a CameraHub supplied through options.cameras is not counted. LiveMetrics.count has no label cap, so I left these two unlabelled rather than per camera.
  • Gauge: sockets_open{kind="live"|"follow"|"machine"|"camera"} goes up at the upgrade in relay.ts and down when the socket closes. All four kinds show 0 from startup. /follow is counted from the upgrade, so a connection that is refused and closed straight away blips it. The /camera/<id>/video sockets are not counted, since the issue lists only the four kinds.
  • Test: a new relay test in relay.test.ts uses a fake MJPEG source. It checks that the camera gauge is 0, then 1 with a socket open, then 0 again after it closes. It also checks that frames-in and bytes-out are above zero while the socket is open.
  • Not touched: forge.json.

Closes #246

commented

/metrics.prom now reports camera frames in, camera bytes out and a gauge of open sockets per kind. bun test in Software/so101 passes (515 tests), but bun x tsc --noEmit does not pass. It reports src/lobby.ts(357,80): 'span' is possibly 'undefined'. That file is untouched here, and the same error shows up with my changes stashed, so I left it alone.

  • Counters: CameraFeed takes an optional metrics in its options. It counts camera_frames_in once per whole part from the source. It counts camera_bytes_out for every byte written to an MJPEG viewer and for each frame sent to a WebSocket sink. The relay passes its LiveMetrics into the feeds it builds, so a CameraHub supplied through options.cameras is not counted. LiveMetrics.count has no label cap, so I left these two unlabelled rather than per camera.
  • Gauge: sockets_open{kind="live"|"follow"|"machine"|"camera"} goes up at the upgrade in relay.ts and down when the socket closes. All four kinds show 0 from startup. /follow is counted from the upgrade, so a connection that is refused and closed straight away blips it. The /camera/<id>/video sockets are not counted, since the issue lists only the four kinds.
  • Test: a new relay test in relay.test.ts uses a fake MJPEG source. It checks that the camera gauge is 0, then 1 with a socket open, then 0 again after it closes. It also checks that frames-in and bytes-out are above zero while the socket is open.
  • Not touched: forge.json.
Approved

Does what #246 asked, and nothing beyond it. The preview serves sockets_open for live, follow, machine and camera at 0 on /metrics.prom. The new relay test covers the camera gauge going 0, 1, 0 and the frame and byte rates above zero. It adds no dependency and only touches the metrics path, so no write or gate changes. I did not run the suite myself; I am relying on the pull saying 515 tests pass and on the forge check. Two things to do next: (1) the /camera/<id>/video sockets are untracked, and CameraHubs passed in through options.cameras are not counted, so add them to the gauge and counters if anyone relies on those numbers. (2) The /follow gauge goes up before the lobby refusal, so refused handshakes briefly show as open sockets. Either count them after the refusal check, or write down that they are counted. The tsc error in lobby.ts is already on main and was not caused by this pull.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs