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
+12
View File
@@ -562,6 +562,12 @@ func TestMetrics(t *testing.T) {
if !bytes.Contains(rec.Body.Bytes(), []byte("negative_cache_hits")) {
t.Error("WriteText output missing negative_cache_hits")
}
if !bytes.Contains(rec.Body.Bytes(), []byte("# HELP total_requests")) {
t.Error("WriteText output missing # HELP total_requests")
}
if !bytes.Contains(rec.Body.Bytes(), []byte("# TYPE total_requests counter")) {
t.Error("WriteText output missing # TYPE total_requests counter")
}
}
// Removed old TestKeyGeneration - replaced with TestURLHashing that uses SHA256
@@ -1128,6 +1134,12 @@ func TestDiskOnlyDelayedAttach(t *testing.T) {
if !bytes.Contains(rec.Body.Bytes(), []byte("capacity_pressure_events")) {
t.Errorf("WriteText output missing capacity_pressure_events: %q", rec.Body.String())
}
if !bytes.Contains(rec.Body.Bytes(), []byte("# TYPE disk_tier_ready gauge")) {
t.Errorf("WriteText output missing # TYPE disk_tier_ready gauge: %q", rec.Body.String())
}
if !bytes.Contains(rec.Body.Bytes(), []byte("# TYPE capacity_pressure_events counter")) {
t.Errorf("WriteText output missing # TYPE capacity_pressure_events counter: %q", rec.Body.String())
}
}
// TestDiskTierSignalMemoryOnly covers memory-only mode: DiskTierReady=1 (N/A, not