Skip to content

feat(metrics): add in-memory Prometheus reporter for counters and gauges - #742

Open
Mohith26 wants to merge 2 commits into
uber:masterfrom
Mohith26:feat/prometheus-metrics-2-reporter
Open

Mohith26 wants to merge 2 commits into
uber:masterfrom
Mohith26:feat/prometheus-metrics-2-reporter

Conversation

@Mohith26

@Mohith26 Mohith26 commented Nov 7, 2026 •

Copy link
Copy Markdown

Depends on #735.

Adds prometheusReporter, which keeps the latest state of each reported series in memory. Counters accumulate the deltas tally reports and gauges keep the latest value. Empty tag values are dropped so they map to the same series as a missing tag (Prometheus treats them the same). If a name is reported as two different metric types, the later type is dropped and a warning is logged once, instead of breaking the scrape later.

Testing: go test -race ./metrics/ (counter/gauge state, empty tag values, type conflicts, name sanitizing), 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) (this PR)
  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)
  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

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