Base-2 exponential histogram aggregator #2261
Closed
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.
Proposed auto-ranging base-2 exponential histogram aggregator.
This uses the logarithm mapping function shown in the reference implementation, see open-telemetry/oteps#179
This uses a circular backing array based on NrSketch WindowedCounterArray. This allows insertion above or below the current dense region in the histogram without moving data until it reaches maximum size. Like that implementation, this implementation uses the smallest integer width bucket possible, from
uint8
throughuint64
.When inserting a value that falls outside the range, the histogram may grow without a change of scale up to maxSize. The implementation will double in size until the maximum is reached.
The ideal scale of any single measurement is computed as 30-math.Abs(normalizedBase2ExponentOf(value)), which results in a bucket index in the range (-231, 231). When a new measurement falls outside the dense region or requires a 31-bit or greater index, the histogram is downscaled in a 2**N-to-1 collapse during which the backing array is rotated.