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:
@@ -313,6 +313,18 @@ func TestRangeMetricsWriteText(t *testing.T) {
|
||||
if !strings.Contains(text, "range_upstream 1\n") {
|
||||
t.Errorf("/metrics missing 'range_upstream 1' line:\n%s", text)
|
||||
}
|
||||
if ct := resp.Header.Get("Content-Type"); ct != "text/plain; version=0.0.4; charset=utf-8" {
|
||||
t.Errorf("/metrics Content-Type=%q, want Prometheus text 0.0.4", ct)
|
||||
}
|
||||
if !strings.Contains(text, "# HELP range_cache ") {
|
||||
t.Errorf("/metrics missing # HELP range_cache:\n%s", text)
|
||||
}
|
||||
if !strings.Contains(text, "# TYPE range_cache counter") {
|
||||
t.Errorf("/metrics missing # TYPE range_cache counter:\n%s", text)
|
||||
}
|
||||
if !strings.Contains(text, "# TYPE range_upstream counter") {
|
||||
t.Errorf("/metrics missing # TYPE range_upstream counter:\n%s", text)
|
||||
}
|
||||
}
|
||||
|
||||
// TestStreamCachedResponseRange206 is a focused unit test for streamCachedResponse:
|
||||
|
||||
Reference in New Issue
Block a user