[PR #251] [MERGED] Opt-in data collection (4/5): the ingest server (SQLite, rollups, retention, aggregate endpoint) #2437

Closed
opened 2026-11-02 15:56:09 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/251
Author: @ludovic111
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/15/2026
Merged by: @ludovic111

Base: main ← Head: feat/telemetry-server


📝 Commits (1)

  • 12c1af0 Opt-in data collection (4/5): the ingest server

📊 Changes

12 files changed (+2413 additions, -2 deletions)

View changed files

➕ .github/workflows/telemetry-server.yml (+34 -0)
📝 Cargo.toml (+1 -1)
➕ crates/horizon-telemetry-server/.gitignore (+1 -0)
➕ crates/horizon-telemetry-server/Cargo.lock (+1106 -0)
➕ crates/horizon-telemetry-server/Cargo.toml (+31 -0)
➕ crates/horizon-telemetry-server/Dockerfile (+13 -0)
➕ crates/horizon-telemetry-server/README.md (+58 -0)
➕ crates/horizon-telemetry-server/src/lib.rs (+307 -0)
➕ crates/horizon-telemetry-server/src/main.rs (+40 -0)
➕ crates/horizon-telemetry-server/src/store.rs (+428 -0)
➕ crates/horizon-telemetry-server/tests/server.rs (+393 -0)
📝 docs/telemetry.md (+1 -1)

📄 Description

What

Fourth of five PRs for opt-in data collection. It's stacked on #248; merged after it, this diff is just the server. No Railway service, volume, database, bucket or domain was created.

crates/horizon-telemetry-server gets its own Cargo workspace (like launcher/), so the game's workspace and its CI never build a web server. It's excluded in the root Cargo.toml, and a path-filtered telemetry-server workflow checks it.

  • POST /v1/batch
    • Decoded by horizon_telemetry::batch::decode: zstd only, at most 256 KiB, bounded inflation, the schema version and every item validated.
    • Answers 204, or 400 / 413 / 415 / 429.
  • DELETE /v1/installs/<id>: deletes every row of that install and rebuilds the days it touched, so its share of the totals goes too.
  • GET /v1/aggregate?days=30: what the website's results page reads.
    • Totals per version, OS, GPU vendor and render distance: sessions, install-days, hours, summed frame buckets, mean p50/p99.
    • Crash counts per version, and the newest 50 benchmark uploads (perf-2's report, kept as uploaded).
    • Groups under 5 install-days are hidden.
    • Cached 10 min, with CORS for playhorizon.dev.
  • GET /healthz

Storage, in one SQLite file (WAL):

  • Machine descriptions are stored once.
  • Each session is a row of columns, with 80-byte binary frame/tick summaries.
  • Crash, bug and benchmark bodies are zstd-compressed.
  • Daily totals (perf_daily) are rebuilt whenever a day changes. They stay after raw rows expire at 180 days.
  • Measured: 190 bytes per play session on disk, indexes included. About 70 MB for 1 000 players × 2 sessions/day × 180 days.

Abuse limits: a token bucket per address (60/h, bursts of 6). Addresses are held in memory only, and the IP is never stored. Each install may send 100 items a day.

Docs: the README has the settings, the Dockerfile (built from the repo root; also checked that the server builds from that minimal context) and hosting costs.

How tested

tests/server.rs, 8 tests:

  • totals with k-anonymity
  • bad batches refused (415/400/413/400)
  • per-address rate limit, with X-Forwarded-For behind a proxy
  • per-install daily cap
  • deletion removes the rows and the totals (cache dropped)
  • retention removes raw rows and keeps the totals
  • storage size
  • end to end with the launcher's real uploader (upload::flush → 204 → totals, then delete_remote → gone)

Full chain on the Mac mini:

  1. The game (#252, consent on, offscreen, 83 s in a world) kept a 693-byte perf summary.
  2. horizon-launcher data send sent it to this server: Sent { items: 1, batches: 1 }.
  3. /v1/aggregate showed the group, with access-control-allow-origin and cache-control.
  4. horizon-launcher data delete left 0 perf / 0 reports / 0 daily rows.

Memory: about 7 MB resident after 50 aggregate requests (debug build).

Self-check:

  • the server's own workspace: cargo fmt --check ✅, cargo clippy --all-targets --locked -D warnings ✅, cargo test --locked ✅ 8 passed
  • root workspace: cargo metadata parses with the new exclude ✅; public tree check ✅

pr_ready doesn't know the server's workspace; the new workflow covers it in CI.

Needs Ludovic: hosting (nothing created)

Recommended: one more service in an existing Railway project (Kira's), running this Dockerfile, with a 1 GB volume at /data and HORIZON_TELEMETRY_TRUST_PROXY=1. At Railway's prices:

Cost per month
RAM (about 15 MB) $0.15
CPU (nearly idle) under $0.05
1 GB volume $0.15
egress (cached JSON) cents
Total about $0.35

That's inside the Hobby plan's included $5 of usage, so about $0 extra if the account's other usage stays under $5. It needs a domain; telemetry.playhorizon.dev is suggested.

Not recommended:

  • Railway Postgres: a few $/month for its memory alone, and buys nothing at this size.
  • A bucket for crash blobs: zstd crash reports are a few KB and fit in the same SQLite file.

Once approved:

  1. Set DEFAULT_ENDPOINT in crates/horizon-telemetry/src/lib.rs. Until then nothing is ever sent.
  2. Set HORIZON_TELEMETRY_ALLOW_ORIGIN if the site's origin differs.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/251 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/telemetry-server` --- ### 📝 Commits (1) - [`12c1af0`](https://github.com/horizon-rust/horizon/commit/12c1af0261529901209c807cd6e5bf1b9458fc29) Opt-in data collection (4/5): the ingest server ### 📊 Changes **12 files changed** (+2413 additions, -2 deletions) <details> <summary>View changed files</summary> ➕ `.github/workflows/telemetry-server.yml` (+34 -0) 📝 `Cargo.toml` (+1 -1) ➕ `crates/horizon-telemetry-server/.gitignore` (+1 -0) ➕ `crates/horizon-telemetry-server/Cargo.lock` (+1106 -0) ➕ `crates/horizon-telemetry-server/Cargo.toml` (+31 -0) ➕ `crates/horizon-telemetry-server/Dockerfile` (+13 -0) ➕ `crates/horizon-telemetry-server/README.md` (+58 -0) ➕ `crates/horizon-telemetry-server/src/lib.rs` (+307 -0) ➕ `crates/horizon-telemetry-server/src/main.rs` (+40 -0) ➕ `crates/horizon-telemetry-server/src/store.rs` (+428 -0) ➕ `crates/horizon-telemetry-server/tests/server.rs` (+393 -0) 📝 `docs/telemetry.md` (+1 -1) </details> ### 📄 Description ## What Fourth of five PRs for opt-in data collection. It's stacked on #248; merged after it, this diff is just the server. **No Railway service, volume, database, bucket or domain was created.** `crates/horizon-telemetry-server` gets its own Cargo workspace (like `launcher/`), so the game's workspace and its CI never build a web server. It's excluded in the root `Cargo.toml`, and a path-filtered `telemetry-server` workflow checks it. - `POST /v1/batch` - Decoded by `horizon_telemetry::batch::decode`: zstd only, at most 256 KiB, bounded inflation, the schema version and every item validated. - Answers 204, or 400 / 413 / 415 / 429. - `DELETE /v1/installs/<id>`: deletes every row of that install and rebuilds the days it touched, so its share of the totals goes too. - `GET /v1/aggregate?days=30`: what the website's results page reads. - Totals per version, OS, GPU vendor and render distance: sessions, install-days, hours, summed frame buckets, mean p50/p99. - Crash counts per version, and the newest 50 benchmark uploads (perf-2's report, kept as uploaded). - Groups under 5 install-days are hidden. - Cached 10 min, with CORS for playhorizon.dev. - `GET /healthz` **Storage, in one SQLite file (WAL):** - Machine descriptions are stored once. - Each session is a row of columns, with 80-byte binary frame/tick summaries. - Crash, bug and benchmark bodies are zstd-compressed. - Daily totals (`perf_daily`) are rebuilt whenever a day changes. They stay after raw rows expire at 180 days. - Measured: **190 bytes per play session on disk**, indexes included. About 70 MB for 1 000 players × 2 sessions/day × 180 days. **Abuse limits:** a token bucket per address (60/h, bursts of 6). Addresses are held in memory only, and the IP is never stored. Each install may send 100 items a day. **Docs:** the README has the settings, the Dockerfile (built from the repo root; also checked that the server builds from that minimal context) and hosting costs. ## How tested `tests/server.rs`, 8 tests: - totals with k-anonymity - bad batches refused (415/400/413/400) - per-address rate limit, with `X-Forwarded-For` behind a proxy - per-install daily cap - deletion removes the rows and the totals (cache dropped) - retention removes raw rows and keeps the totals - storage size - **end to end with the launcher's real uploader** (`upload::flush` → 204 → totals, then `delete_remote` → gone) Full chain on the Mac mini: 1. The game (#252, consent on, offscreen, 83 s in a world) kept a 693-byte perf summary. 2. `horizon-launcher data send` sent it to this server: `Sent { items: 1, batches: 1 }`. 3. `/v1/aggregate` showed the group, with `access-control-allow-origin` and `cache-control`. 4. `horizon-launcher data delete` left 0 perf / 0 reports / 0 daily rows. Memory: about 7 MB resident after 50 aggregate requests (debug build). Self-check: - the server's own workspace: `cargo fmt --check` ✅, `cargo clippy --all-targets --locked -D warnings` ✅, `cargo test --locked` ✅ 8 passed - root workspace: `cargo metadata` parses with the new `exclude` ✅; public tree check ✅ pr_ready doesn't know the server's workspace; the new workflow covers it in CI. ## Needs Ludovic: hosting (nothing created) **Recommended:** one more service in an existing Railway project (Kira's), running this Dockerfile, with a 1 GB volume at `/data` and `HORIZON_TELEMETRY_TRUST_PROXY=1`. At Railway's prices: | | Cost per month | |---|---| | RAM (about 15 MB) | $0.15 | | CPU (nearly idle) | under $0.05 | | 1 GB volume | $0.15 | | egress (cached JSON) | cents | | **Total** | **about $0.35** | That's inside the Hobby plan's included $5 of usage, so about **$0 extra** if the account's other usage stays under $5. It needs a domain; `telemetry.playhorizon.dev` is suggested. **Not recommended:** - **Railway Postgres:** a few $/month for its memory alone, and buys nothing at this size. - **A bucket for crash blobs:** zstd crash reports are a few KB and fit in the same SQLite file. Once approved: 1. Set `DEFAULT_ENDPOINT` in `crates/horizon-telemetry/src/lib.rs`. Until then nothing is ever sent. 2. Set `HORIZON_TELEMETRY_ALLOW_ORIGIN` if the site's origin differs. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:56:09 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2437
No description provided.