Repository navigation
feat(metrics): use shared bucket sets for the classic histograms - #3828
Draft
pbleser-oc wants to merge 2 commits into
Draft
pbleser-oc wants to merge 2 commits into
pbleser-oc wants to merge 2 commits into
Conversation
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
Add four bucket sets to pkg/metrics, so that the classic histograms of the services use consistent boundaries, each with about a dozen buckets: RequestDurationBuckets 0.01 .. 60s (12 buckets) FastOperationDurationBuckets 0.001 .. 10s (13 buckets) TransferDurationBuckets 0.01 .. 1800s (14 buckets) ProcessingDurationBuckets 0.1 .. 1200s (12 buckets) and use them in the services (the number of buckets before -> after): graph http_request_duration_seconds DefBuckets -> request (11 -> 12) graph identity_backend_api_duration_seconds DefBuckets -> request (11 -> 12) graph ldap_client_operation_duration_seconds DefBuckets -> fast operation (11 -> 13) invitations invitation_duration_seconds DefBuckets -> request (11 -> 12) webfinger webfinger_duration_seconds DefBuckets -> fast operation (11 -> 13) proxy duration_seconds DefBuckets -> transfer (11 -> 14) proxy service_duration_seconds DefBuckets -> transfer (11 -> 14) search search_duration_seconds 0.1 .. 60s -> request (8 -> 12) search index_duration_seconds unchanged (processing) postprocessing duration_seconds unchanged (processing) prometheus.DefBuckets (0.005 .. 10s) put everything slower than 10s into the +Inf bucket, e.g. slow Graph API calls and identity backend operations, and the uploads and downloads that go through the proxy (which also measures the transfer of the body), while it barely resolved LDAP operations, which mostly take a few milliseconds. The new boundaries are estimates, which can be refined once the native histograms show the actual distributions. Changing the bucket boundaries breaks the continuity of the _bucket series of these histograms: queries over a time range that includes the upgrade mix old and new boundaries. The affected metrics are: - opencloud_graph_http_request_duration_seconds - opencloud_graph_identity_backend_api_duration_seconds - opencloud_graph_ldap_client_operation_duration_seconds - opencloud_invitations_invitation_duration_seconds - opencloud_webfinger_webfinger_duration_seconds - opencloud_proxy_duration_seconds - opencloud_proxy_service_duration_seconds - opencloud_search_search_duration_seconds The boundaries of opencloud_search_index_duration_seconds and opencloud_postprocessing_duration_seconds don't change. Fixes opencloud-eu#3823
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 13 |
🟢 Coverage 47.37% diff coverage · 0.00% coverage variation
Metric Results Coverage variation ✅ 0.00% coverage variation (-1.00%) Diff coverage ✅ 47.37% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (4c6d7e7) 92640 25430 27.45% Head commit (ca9893d) 92658 (+18) 25433 (+3) 27.45% (0.00%) 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 (#3828) 38 18 47.37% 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 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 #3823 (part of #3817)
Note
This PR builds on #3825, whose commit is included here until #3825 is merged; this PR will then be rebased onto
main. Only the last commit, ca9893d ("use shared bucket sets for the classic histograms"), belongs to this PR. To review only that, use the diff of that commit orgit show ca9893db29.Changes
Four shared bucket sets in
pkg/metrics, so that the classic histograms of the services use consistent boundaries, each with about a dozen buckets:RequestDurationBucketsFastOperationDurationBucketsTransferDurationBucketsProcessingDurationBucketsUsed by the services (number of buckets before → after):
opencloud_graph_http_request_duration_secondsDefBuckets(11)opencloud_graph_identity_backend_api_duration_secondsDefBuckets(11)opencloud_graph_ldap_client_operation_duration_secondsDefBuckets(11)opencloud_invitations_invitation_duration_secondsDefBuckets(11)opencloud_webfinger_webfinger_duration_secondsDefBuckets(11)opencloud_proxy_duration_secondsDefBuckets(11)opencloud_proxy_service_duration_secondsDefBuckets(11)opencloud_search_search_duration_secondsopencloud_search_index_duration_secondsopencloud_postprocessing_duration_secondsWhy:
prometheus.DefBuckets(0.005 – 10s) puts everything slower than 10s into the+Infbucket, e.g. slow Graph API calls and identity backend operations, and the uploads and downloads that go through the proxy (which also measures the transfer of the body). At the same time, it barely resolves LDAP operations, which mostly take a few milliseconds.The new boundaries are estimates, which can be refined once the native histograms (#3825) show the actual distributions.
Impact
_bucketseries of the first eight metrics in the table above: queries over a time range that includes the upgrade mix old and new boundaries. This should be mentioned in the release notes.opencloud_graph_http_request_duration_seconds(+1 bucket), roughly 90 for the two proxy histograms (+3 buckets each), a handful for the others.Tests
go build,go vetand the tests of the affected packages pass.