metrics: Prometheus text exposition for /metrics
CI / vulncheck (pull_request) Successful in 14s
CI / check-and-test (pull_request) Successful in 42s

/metrics was Prometheus-ish name/value text with a custom banner and
text/plain Content-Type, so strict scrapers could fail.

Emit Prometheus text 0.0.4 (# HELP, # TYPE, counter|gauge) with stable
metric names, and set Content-Type to text/plain; version=0.0.4; charset=utf-8.
This commit is contained in:
2026-09-08 19:53:58 +00:00
parent 0db9943436
commit dd72668c2d
7 changed files with 200 additions and 29 deletions
+2 -2
View File
@@ -76,9 +76,9 @@ func (sc *SteamCache) handleSpecialEndpoints(w http.ResponseWriter, r *http.Requ
}
if r.URL.String() == "/metrics" {
// Return metrics in a simple text format
// Prometheus text exposition format 0.0.4
stats := sc.GetMetrics()
w.Header().Set("Content-Type", "text/plain")
w.Header().Set("Content-Type", "text/plain; version=0.0.4; charset=utf-8")
w.WriteHeader(http.StatusOK)
metrics.WriteText(w, stats)
return true