metrics: Prometheus text exposition for /metrics
/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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user