Repository navigation
feat(metrics): expose histograms in both classic and native form - #3825
Open
pbleser-oc wants to merge 1 commit into
Open
pbleser-oc wants to merge 1 commit into
pbleser-oc wants to merge 1 commit into
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 10 |
🟢 Coverage 54.84% diff coverage · +0.01% coverage variation
Metric Results Coverage variation ✅ +0.01% coverage variation (-1.00%) Diff coverage ✅ 54.84% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (4c6d7e7) 92640 25430 27.45% Head commit (6ab5d13) 92654 (+14) 25445 (+15) 27.46% (+0.01%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#3825) 31 17 54.84% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This was referenced Oct 26, 2026
Add the helpers DualHistogramOpts and NativeHistogramOpts to pkg/metrics, which add the settings for the native part of a Prometheus histogram, with the same hardcoded defaults for all services (bucket factor 1.1, at most 100 buckets, never reset). Native histograms that exceed the limit of 100 buckets are never reset (NativeHistogramMinResetDuration is 0): client_golang reduces the resolution of their native part instead (until the process restarts). A reset would set the whole histogram back to zero, including its classic buckets, count and sum, i.e. a counter reset about once an hour (with a minimum reset duration of 1 hour) for every scraper, also for those that only ingest the classic histogram. The classic histograms of the graph, postprocessing, search, invitations and webfinger services now use DualHistogramOpts, so that they are exposed in both classic and native form: Prometheus scrapers without native histograms (the default) keep ingesting the classic buckets, while scrapers with scrape_native_histograms enabled ingest the native histogram instead (and the classic one as well if always_scrape_classic_histograms is enabled). Histograms that didn't define buckets keep prometheus.DefBuckets. The native-only request_duration_seconds histogram of the proxy service now uses NativeHistogramOpts, which additionally caps its number of buckets. The classic duration_seconds and service_duration_seconds histograms of the proxy service remain classic-only on purpose: they are the fallback for scrapers without native histograms, and their native form would only duplicate request_duration_seconds. Cost: the native part adds about 120 bytes of heap per native bucket to every label combination (child) of a histogram. Measured with values spread over 1ms-100ms, 1ms-10s and 100us-1000s, a child grows from about 1.2 KB (classic only) to 8 KB, 8.5 KB and 12.7 KB (54, 54 and 94 native buckets); with the cap of 100 buckets, it stays below about 13 KB. graph's http_request_duration_seconds has the most children (about 85 routes times the status codes that actually occur, typically a few hundred), i.e. about 2-4 MB more; all other histograms have at most a few dozen children, adding less than 1 MB together. Fixes opencloud-eu#3822
pbleser-oc
force-pushed
the
feat/3822-native-histograms
branch
from
October 26, 2026 18:37
e23ef39 to
6ab5d13
Compare
This was referenced Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3822 (part of #3817)
Changes
pkg/metrics:DualHistogramOpts: adds the native histogram settings, so the histogram is exposed in both classic and native form. If noBucketsare set, it usesprometheus.DefBuckets, becauseclient_golangotherwise exposes no classic buckets once native buckets are enabled.NativeHistogramOpts: native-only, for histograms with high cardinality that have classic fallback metrics with fewer labels.1.1(≈10% relative error), at most100buckets, never reset (NativeHistogramMinResetDurationis 0): when a histogram exceeds 100 native buckets, client_golang reduces the resolution of its native part instead. A reset would set the whole histogram back to zero, including its classic buckets,_countand_sum, i.e. a counter reset also for scrapers that only ingest the classic histogram.DualHistogramOpts: graph (http_request_duration_seconds,ldap_client_operation_duration_seconds,identity_backend_api_duration_seconds), postprocessing, search, invitations and webfinger. Their classic buckets are unchanged.request_duration_secondsusesNativeHistogramOpts, which adds the bucket cap to its existing native-only setup. proxy's classicduration_secondsandservice_duration_secondsstay classic-only on purpose: they are the fallback for scrapers without native histograms, and their native form would only duplicaterequest_duration_seconds.Cost
The native part adds about 120 bytes of heap per native bucket to every label combination of a histogram. Measured with values spread over 1ms–100ms, 1ms–10s and 100µs–1000s, a label combination grows from about 1.2 KB (classic only) to 8 KB, 8.5 KB and 12.7 KB (54, 54 and 94 native buckets). With the cap of 100 buckets, it stays below about 13 KB.
graph's
http_request_duration_secondshas the most label combinations (about 85 routes times the status codes that actually occur, typically a few hundred), so about 2–4 MB more. All other histograms have at most a few dozen label combinations, adding less than 1 MB together.Impact on Prometheus setups
scrape_native_histograms: false): nothing changes. The classic histograms are ingested as before.scrape_native_histograms: true, or--enable-feature=native-histogramsbefore Prometheus v3.9): for every histogram that now usesDualHistogramOpts, Prometheus now stores only the native form. The classic_bucket,_sumand_countseries stop, so dashboards, recording rules and alerts that use them go empty until they are rewritten for native histograms (e.g.histogram_quantile(0.99, rate(x[5m])),histogram_count(rate(x[5m])),histogram_sum(rate(x[5m]))). To keep the classic series as well, for example while migrating dashboards, setalways_scrape_classic_histograms: truein the scrape config.This should be mentioned in the release notes.
Tests
pkg/metrics/histogram_test.go: they check the classic buckets (explicit and default) and the native part of what a histogram exposes.go build,go vetand the tests of the affected packages pass.