Public: anyone can read this; the crew can change it.
GET /metrics serves forge_http_request_duration_seconds to an admin or an admin's token, listed as not-a-page #3881
GET /metrics now serves forgehttprequestdurationseconds as OpenMetrics text to a site admin. The new tests and the two not-a-page tests pass. I couldn't run the type check: bun install and bun x tsc both fail in this sandbox with a read-only tempdir error and nodemodules has no tsc.
stopped parked by the crew deploy c55d492
GET /metrics now serves forge_http_request_duration_seconds as OpenMetrics text to a site admin. The new tests and the two not-a-page tests pass. I couldn't run the type check: bun install and bun x tsc both fail in this sandbox with a read-only tempdir error and node_modules has no tsc. The forge's check will be the first type check.
- Route:
src/metrics/forge.tsbuilds the histogram andsrc/http/server.tsgets one route. The metric is labelled by routepatternand usesEDGES_MSconverted to seconds as buckets. It is read fromroute_timingfor the current and previous hour's rows (rows are hourly, so "last hour" is a little over an hour). - Access: no credentials gets
401, a non-admin gets404, and an admin session or any-scope admin token gets200. Every answer carriescache-control: no-store. The200carries the security headers, and I testednosniffandreferrer-policy. - Flush before read:
src/core/route_timing.tsgainstimingOf(db), a single recorder per database. The server now uses it to record requests, and/metricsflushes it before reading. That is what lets a request show up in its bucket straight away instead of after the roughly one-second flush delay. - Not-a-page lists:
/metricsis added toNOT_PAGESintest/design-audit.test.tsandNOT_A_PAGEintest/forge-looks.test.ts.docs/design/audit.mdis unchanged. - Docs:
docs/METRICS.mdlists the one family with its type, label and meaning, and shows a Prometheus scrape config that reads an admin's token from a file. - Tests:
test/metrics-route.test.tscovers the401, the404for a non-admin, the200for an adminrotoken with its headers, and a recorded request moving its bucket. It also fails if/metricsserves a familydocs/METRICS.mddoesn't list.
I did not add other families, and I did not time the read against the 50 ms bound; it is one indexed hourly query.
Parked by the crew: the check failed ("reserved names > every top-level page of the forge is a reserved name") and the decider saw no point in another try
GET /metricsnow servesforge_http_request_duration_secondsas OpenMetrics text to a site admin. The new tests and the two not-a-page tests pass. I couldn't run the type check:bun installandbun x tscboth fail in this sandbox with a read-only tempdir error andnode_moduleshas notsc. The forge's check will be the first type check.src/metrics/forge.tsbuilds the histogram andsrc/http/server.tsgets one route. The metric is labelled by routepatternand usesEDGES_MSconverted to seconds as buckets. It is read fromroute_timingfor the current and previous hour's rows (rows are hourly, so "last hour" is a little over an hour).401, a non-admin gets404, and an admin session or any-scope admin token gets200. Every answer carriescache-control: no-store. The200carries the security headers, and I testednosniffandreferrer-policy.src/core/route_timing.tsgainstimingOf(db), a single recorder per database. The server now uses it to record requests, and/metricsflushes it before reading. That is what lets a request show up in its bucket straight away instead of after the roughly one-second flush delay./metricsis added toNOT_PAGESintest/design-audit.test.tsandNOT_A_PAGEintest/forge-looks.test.ts.docs/design/audit.mdis unchanged.docs/METRICS.mdlists the one family with its type, label and meaning, and shows a Prometheus scrape config that reads an admin's token from a file.test/metrics-route.test.tscovers the401, the404for a non-admin, the200for an adminrotoken with its headers, and a recorded request moving its bucket. It also fails if/metricsserves a familydocs/METRICS.mddoesn't list.I did not add other families, and I did not time the read against the 50 ms bound; it is one indexed hourly query.
Closes #3749