metrics: Prometheus text exposition for /metrics #51

Merged
eva merged 1 commits from metrics/prometheus-exposition into main 2026-09-08 14:57:22 -05:00
Collaborator

Why

/metrics was Prometheus-ish plain name value text with a custom # SteamCache2 Metrics banner and Content-Type: text/plain. Strict scrapers (Prometheus, Grafana Alloy) can reject that. Jerry's lab Prom/Grafana scrape needs a clean exposition format without changing which metrics exist.

What changed

  • WriteText now emits Prometheus text exposition format 0.0.4: # HELP name …, # TYPE name counter|gauge, then the sample line(s).
  • Removed the non-standard banner. Metric names are unchanged; labeled series still use service=%q.
  • /metrics Content-Type is text/plain; version=0.0.4; charset=utf-8.
  • README notes the scrape format. /lancache-heartbeat is unchanged.

How tested

  • go test ./steamcache/metrics/ ./steamcache/ -count=1 (pass)
  • Existing sample-line assertions kept (capacity_pressure_events, negative_cache_hits, disk_tier_ready, range_cache, …)
  • Added # HELP / # TYPE checks and /metrics Content-Type assertions

Risks

  • Scrapers or make validate-check that grepped the old banner will no longer see it (sample lines are unchanged).
  • service label is unchanged (Prometheus may still rename it to exported_service; that is issue #41, not this PR).

Rollback

Revert this PR.

Closes #49

## Why `/metrics` was Prometheus-ish plain `name value` text with a custom `# SteamCache2 Metrics` banner and `Content-Type: text/plain`. Strict scrapers (Prometheus, Grafana Alloy) can reject that. Jerry's lab Prom/Grafana scrape needs a clean exposition format without changing which metrics exist. ## What changed - `WriteText` now emits Prometheus text exposition format 0.0.4: `# HELP name …`, `# TYPE name counter|gauge`, then the sample line(s). - Removed the non-standard banner. Metric names are unchanged; labeled series still use `service=%q`. - `/metrics` `Content-Type` is `text/plain; version=0.0.4; charset=utf-8`. - README notes the scrape format. `/lancache-heartbeat` is unchanged. ## How tested - `go test ./steamcache/metrics/ ./steamcache/ -count=1` (pass) - Existing sample-line assertions kept (`capacity_pressure_events`, `negative_cache_hits`, `disk_tier_ready`, `range_cache`, …) - Added `# HELP` / `# TYPE` checks and `/metrics` Content-Type assertions ## Risks - Scrapers or `make validate-check` that grepped the old banner will no longer see it (sample lines are unchanged). - `service` label is unchanged (Prometheus may still rename it to `exported_service`; that is issue #41, not this PR). ## Rollback Revert this PR. Closes #49
pike added 1 commit 2026-09-08 14:54:24 -05:00
metrics: Prometheus text exposition for /metrics
CI / vulncheck (pull_request) Successful in 14s
CI / check-and-test (pull_request) Successful in 42s
dd72668c2d
/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.
pike requested review from eva 2026-09-08 14:54:24 -05:00
eva approved these changes 2026-09-08 14:57:22 -05:00
eva left a comment
Owner

LGTM — Prometheus 0.0.4 HELP/TYPE + scrape Content-Type; /lancache-heartbeat untouched; counters cumulative; service→exported_service left to #41 as noted. CI green.

LGTM — Prometheus 0.0.4 HELP/TYPE + scrape Content-Type; /lancache-heartbeat untouched; counters cumulative; service→exported_service left to #41 as noted. CI green.
eva merged commit 7c34ff4538 into main 2026-09-08 14:57:22 -05:00
eva deleted branch metrics/prometheus-exposition 2026-09-08 14:57:22 -05:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: s1d3sw1ped/steamcache2#51