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

Games survival step 2b: read FabricExporter Prometheus metrics at check-in so TPS and tick time show on the games page #18116

opened this

Merged 8h 23m ago, live in production

This pull reads FabricExporter's Prometheus page at check-in, so a Fabric server's TPS and tick time now reach the games page. I ran bun test test/game-metrics.test.ts, bun x tsc --noEmit and bun scripts/gate.ts, and all pass. I did not run the full suite, and I did not run the agent script against a real container.

Notes

opened this

This pull reads FabricExporter's Prometheus page at check-in, so a Fabric server's TPS and tick time now reach the games page. I ran bun test test/game-metrics.test.ts, bun x tsc --noEmit and bun scripts/gate.ts, and all pass. I did not run the full suite, and I did not run the agent script against a real container.

  • Agent (src/games/agent.sh): when rcon-cli tps says nothing, which a Fabric server does, it reads http://127.0.0.1:25585/metrics inside the container. It keeps only the tick, TPS and mspt lines, capped at 4 KB, and sends them as prom beside list, tps and mspt. I only syntax-checked the script (bash -n).
  • Parser (parsePrometheus in src/games/metrics.ts): takes the TPS, or the tick time in ms or seconds. If only tick time is present it derives TPS, capped at 20. recordMetrics uses Paper's answer first and falls back to it, so Paper servers behave as before and nothing outside game_metric changed.
  • Metric names are a guess: I could not reach the exporter from here, so the names are mc_/minecraft_ followed by tps, or tick_time/tick_duration/mspt with an _ms, _milliseconds or _seconds suffix. Please check them against a real FabricExporter before relying on them.
  • Both doors: the page already drew TPS and tick time from game_metric, so it needed no change. The terminal's Games screen showed only TPS, so it now shows N ms tick beside it (src/tui/screens/games.ts). docs/features/games.md is updated.
  • Tests (test/game-metrics.test.ts): the parser, and a Fabric sync recorded into the series.
  • Reused: recordMetrics' existing upsert and rollup. I added no module-level state and no new exports beyond parsePrometheus, which recordMetrics calls.
  • Not done: the exporter's per-dimension or per-player samples, and installing the mod for a box.

Try: open /games/<box> for a Fabric box with FabricExporter and look at Numbers for TPS and Tick time; the terminal's Games screen lists both.

Closes #18088

commented

This update adds the missing tests and documentation. It doesn't fully meet point 2: I couldn't check the metric names against a real FabricExporter page. The two test files pass (test/game-metrics.test.ts and test/tui-games.test.ts), and tsc is clean. I didn't run the rest of the suite.

Changes

  • Terminal test: a new test in test/tui-games.test.ts records a Fabric prom sample with recordMetrics and renders the Games list. It expects 18.5 TPS · 7.5 ms tick. It also covers mspt being null, where ms tick is absent.
  • Boundary test: a new test in test/game-metrics.test.ts shows the prom field is cut at 16 KB. A sample past the cut is ignored, one inside it is read, and a number or an object gives nothing.
  • Parser comment: the comment above PROM_TPS in src/games/metrics.ts now says the parser decides what counts. The agent.sh comment says the same about its looser grep.
  • Docs: the Numbers section of docs/features/games.md now says four things:
    • FabricExporter must be installed on the Fabric server, and the forge doesn't install it.
    • The agent reads 127.0.0.1:25585/metrics inside the container with curl.
    • It lists the metric names that are read.
    • A mod that spells the names differently shows no numbers and no error.

What I couldn't do

  • Metric names: no real FabricExporter sample was reachable from this sandbox, so I did not invent one as a fixture. The comment and the docs say plainly that the names are the conventional spellings and unverified. A reviewer who has a captured page should add it as a fixture or correct the names.
  • Port 25585: this is also unverified. It is the default the agent already assumed.

What I left out

  • A configurable port or metric-name list.
  • Installing the exporter from the forge.

Check for the gate: gate --explain and --fix ran. The only note was two long comment lines that the nightly rewrap handles on main. The commit line does not carry a No door: line. It touches the terminal and the doc, which already existed for this feature.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs