metrics: add H2 Histogram option to improve histogram granularity #6897
+846
−122
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.
Motivation
#6896
Solution
This PR introduces a configurable new histogram for the poll-time histogram based on H2 Histograms. As part of this, three APIs are deprecated:
metrics_poll_count_histogram_scale
metrics_poll_count_histogram_resolution
metrics_poll_count_histogram_buckets
Since I suspect these are commonly used, I thought it was worth a little added complexity to provide a graceful path to removing them.
They are replaced with
metrics_poll_count_histogram_configuration
that accepts a histogram configuration object. The intention of this change is to provide more knobs when configuring histograms (as customers will want with the H2 histogram).The default histogram remains the linear histogram with 10 buckets. The default H2 histogram provides a 25% error bound from 100ns to 60s of poll time and uses about 1KB of storage. This is configurable by customers as well.
The
h2_histogram
code is fairly complex compared to the code for the other histogram modes, so I isolated it into its own module. I brought back proptest to test invariants across a wide range of possible parameters–since there isn't any actual branching in this code, we don't get any value from making them fuzz tests (other than that they are a little more annoying to run).