Public: anyone can read this; the crew can change it.
The existing GET /metrics also serves forge_http_request_duration_seconds, and docs/METRICS.md lists every family #3975
Sign in to join this conversation.
Public: anyone can read this; the crew can change it.
Part of the owner's Observability 1 ask (#3690). Replaces #3749, which tried to add a second
/metricsroute. Main already has one:src/http/api.ts(router.add("GET", "/metrics", …), #3719/#3721). It is on the API router, andsrc/http/server.tssends/metricsthere. It is admin-only throughaccountAdmin(ctx, "ro")and serves the egress families fromsrc/apps/egress_metrics.ts. Extend that route. Add no route to the web router: a web-router route is what failedreserved names > every top-level page of the forge is a reserved name.Done:
GET /metricshandler insrc/http/api.tsnow also answers withforge_http_request_duration_seconds. That family is a histogram labelled by routepattern, read fromroute_timing(src/core/route_timing.ts) over the last hour, with that module'sEDGES_MSas buckets in seconds. It is built in a newsrc/metrics/forge.tswithsrc/metrics/openmetrics.ts. The egress families stay byte-for-byte what they are, sotest/egress-metrics-route.test.tspasses unchanged.text/plain; version=0.0.4, or move the whole answer toapplication/openmetrics-text; version=1.0.0; charset=utf-8with a trailing# EOF. Either way, one format for the whole body, and the pull says which.cache-control: no-storeare unchanged: 401 without credentials, 404 for a non-admin, and 200 for an admin'srotoken.docs/METRICS.md(new) lists every family/metricsserves (egress and duration) with its type, labels and meaning, and how to point Prometheus at it with an adminrotoken. A test fails if the route serves a family the doc does not list.route_timingand sees its bucket move on/metrics.bun test test/egress-metrics-route.test.ts test/reserved-names.test.ts test/design-audit.test.ts test/forge-looks.test.tspasses. Neither audit list norsrc/core/reserved.tsneeds to change; if one does, the route went to the wrong router.Files:
src/metrics/forge.ts(new),src/http/api.ts(the existing handler),docs/METRICS.md(new), a test such astest/metrics-route.test.ts(new). Risk: the route names every route pattern, so it stays admin-only. Keep the hour's read under 50 ms (one indexed query). If the check fails where it ran and not in the change, say so in the pull rather than reworking the change.