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

Route p95 per hour is kept for seven days, so a slow week can be told from a slow minute #11500

opened this

Check · Review · Land · Live — No review yet. Next: reviewer, no review yet.

Ready to land

Route p50 and p95 are now kept per hour for seven days, and an admin can read them at `GET /api/v1/telemetry/routes?hours=N`.

10 files · +245 −2

look green — ready for a look deploy 8069cf2

Checked against an older mainCheck of 8069cf2checked against main at e409fe8fast tier: green in 10m58s · full gate runs on land

Website spec: 23 findings (report only)
opened this

Route p50 and p95 are now kept per hour for seven days, and an admin can read them at GET /api/v1/telemetry/routes?hours=N.

What changed

  • Table: a new route_hour table (migration 20261111160000-route-hour, pinned) holds route, hour, n, p50 and p95.
  • Writer: src/perf/history.ts does the write. The watcher in src/perf/duty.ts calls it once per hour, outside request handling. It keeps at most 200 routes, the busiest first, and deletes rows 168 hours or older in the same transaction. Writing the same hour again replaces the row.
  • Route: GET /api/v1/telemetry/routes?hours=N is admin-only. hours is a whole number from 1 to 168 and defaults to 24. Anything else returns 400 invalid_hours, a non-admin gets 403, and no credentials get 401. The handler in src/http/api.ts is a few lines delegating to history.ts.
  • Contract: the route is in the OpenAPI contract as getApiV1TelemetryRoutes.
  • Docs: docs/features/performance-watcher.md describes it.
  • Tests: test/perf-history.test.ts covers the write, the 200-route cap, the purge of an 8-day-old row, hours validation including 0, and the endpoint. test/perf-duty.test.ts covers the hourly write and that the same hour is not rewritten. bun scripts/gate.ts, tsc --noEmit, design-lint and the openapi-coverage, drift and limit-bounds tests pass. I ran only the tests covering this change, not the full suite.

Not done

  • The in-memory record keeps only the last 15 minutes, so each hourly row summarises the 15 minutes ending when it is written, not the whole hour. Making it the whole hour would need a running per-hour accumulator in the record; the docs say this plainly.
  • A restart within the same hour rewrites that hour's row over the first.
  • No page or MCP tool shows these rows yet; the API is the only way in.

Try it Call curl -H "authorization: Bearer <admin token>" "$FORGE_URL/api/v1/telemetry/routes?hours=24". Rows appear after the first hourly tick. The pre-push hook required a "Try:" commit message, so there is an empty commit saying how to try it.

Closes #11477

commented

Route p50 and p95 are now kept per hour for seven days, and an admin can read them at GET /api/v1/telemetry/routes?hours=N.

What changed

  • Table: a new route_hour table (migration 20261111160000-route-hour, pinned) holds route, hour, n, p50 and p95.
  • Writer: src/perf/history.ts does the write. The watcher in src/perf/duty.ts calls it once per hour, outside request handling. It keeps at most 200 routes, the busiest first, and deletes rows 168 hours or older in the same transaction. Writing the same hour again replaces the row.
  • Route: GET /api/v1/telemetry/routes?hours=N is admin-only. hours is a whole number from 1 to 168 and defaults to 24. Anything else returns 400 invalid_hours, a non-admin gets 403, and no credentials get 401. The handler in src/http/api.ts is a few lines delegating to history.ts.
  • Contract: the route is in the OpenAPI contract as getApiV1TelemetryRoutes.
  • Docs: docs/features/performance-watcher.md describes it.
  • Tests: test/perf-history.test.ts covers the write, the 200-route cap, the purge of an 8-day-old row, hours validation including 0, and the endpoint. test/perf-duty.test.ts covers the hourly write and that the same hour is not rewritten. bun scripts/gate.ts, tsc --noEmit, design-lint and the openapi-coverage, drift and limit-bounds tests pass. I ran only the tests covering this change, not the full suite.

Not done

  • The in-memory record keeps only the last 15 minutes, so each hourly row summarises the 15 minutes ending when it is written, not the whole hour. Making it the whole hour would need a running per-hour accumulator in the record; the docs say this plainly.
  • A restart within the same hour rewrites that hour's row over the first.
  • No page or MCP tool shows these rows yet; the API is the only way in.

Try it Call curl -H "authorization: Bearer <admin token>" "$FORGE_URL/api/v1/telemetry/routes?hours=24". Rows appear after the first hourly tick. The pre-push hook required a "Try:" commit message, so there is an empty commit saying how to try it.

commented

Route p50/p95 per hour is kept for seven days in route_hour, written hourly by the watcher, and an admin reads it at GET /api/v1/telemetry/routes?hours=24.

The check failed because the generated OpenAPI route index didn't list the new endpoint. I regenerated src/contract/openapi/routes/index.ts with bun scripts/openapi-routes.ts and pushed.

The OpenAPI tests and the "gathered routes" tests pass locally, and tsc --noEmit is clean. I did not run the full suite; the forge's check does that on this push.

To try it, call the endpoint above with an admin bearer token.

I left out any page for this data.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs