Skip to content

feat(metrics): add Prometheus backend config - #746

Open
Mohith26 wants to merge 6 commits into
uber:masterfrom
Mohith26:feat/prometheus-metrics-6-config
Open

Mohith26 wants to merge 6 commits into
uber:masterfrom
Mohith26:feat/prometheus-metrics-6-config

Conversation

@Mohith26

@Mohith26 Mohith26 commented Nov 7, 2026 •

Copy link
Copy Markdown

Depends on #745.

Adds PrometheusConfig under metrics.prometheus: listen_address (required), handler_path (default /metrics), prefix (default kraken) and timer_buckets (default exponential buckets from 1ms to ~65s), with validation. The backend is wired up in #747.

Testing: go test -race ./metrics/ (defaults and validation errors), golangci-lint run ./metrics/... (0 issues), go build ./....

Stack (merge in order):

  1. feat(metrics): add Prometheus name sanitizing and series key helpers #735 Name sanitizing and series key helpers (61 lines)
  2. feat(metrics): add in-memory Prometheus reporter for counters and gauges #742 In-memory reporter for counters and gauges (118 lines)
  3. feat(metrics): report tally timers as histograms in seconds #743 Tally timers as histograms in seconds (83 lines)
  4. feat(metrics): report tally histograms to the Prometheus reporter #744 Tally value/duration histograms (completes tally.StatsReporter) (87 lines)
  5. feat(metrics): expose the Prometheus reporter as a prometheus.Collector #745 prometheus.Collector with label padding, client_golang v1.20.5 bump (132 lines)
  6. feat(metrics): add Prometheus backend config #746 PrometheusConfig defaults and validation (85 lines) (this PR)
  7. feat(metrics): add a Prometheus metrics backend #747 Register the prometheus backend (HTTP server, Close) and docs (113 lines)

Since these come from a fork, each PR is based on master and also contains the commits of the PRs before it, so the diff and the size check here include those until they merge. Only the last commit is new in this PR. I'll rebase each one as the earlier ones land. Line counts are additions in non-test files, which is what the size check counts.

First part of a Prometheus metrics backend. Adds helpers that turn tally
metric and tag names into valid Prometheus names and build a unique key
for a series from its name and labels.

Part of uber#161
Adds prometheusReporter, which keeps the latest state of every reported
series in memory: counters accumulate the deltas tally reports and gauges
keep the latest value. A name reported as two different metric types is
logged once and the later type is dropped.

Part of uber#161
Adds histogram state to prometheusReporter series and reports tally
timers as histograms in seconds, using a configurable set of bucket
upper bounds.

Part of uber#161
Handles tally value and duration histograms, which only report how many
samples fell in each bucket, so the histogram sum is estimated from the
bucket bounds. With this prometheusReporter implements
tally.StatsReporter.

Part of uber#161
prometheusReporter now implements prometheus.Collector. Prometheus needs
every series of a metric to share label names, but tally does not, so at
collect time missing labels are padded with empty values, which
Prometheus treats as absent, instead of dropping series.

Bumps prometheus/client_golang from v0.9.3 (indirect, via
docker/distribution) to v1.20.5.

Part of uber#161
Adds PrometheusConfig under metrics.prometheus with defaults (handler
path /metrics, prefix kraken, timer buckets from 1ms to ~65s) and
validation. The backend itself is wired up in a follow-up.

Part of uber#161

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant