Exponential histogram (OpenTelemetry)
An OpenTelemetry exponential histogram represents measurement counts in magnitude buckets with boundaries determined by an integer scale.
For positive values, bucket i covers (base^i, base^(i+1)], with base = 2^(2^(-scale)). Negative magnitudes have a separate range; a configurable zero bucket is separate again. Lowering the scale combines aligned buckets exactly, but loses the finer partition. This is called perfect subsetting. [1]
Exact regrouping of counts does not recover individual measurements or exact percentiles. In Hesela's constructed 100-duration example, two populations yield the same scale-0 histogram, count, sum, minimum and maximum. Their nearest-rank p99 values are 1.4 ms and 1.6 ms. Both map to 100 observations in (1, 2] ms; this is deliberate information loss, not a faulty count merge. [2]
The calculation uses exact rational values and checks that direct scale-0 counting equals scale-2 counting followed by downscaling. Signed bucket indexes need floor division: a fine index of -1 remains negative when coarsened, rather than truncating to 0. The downloadable model is an arithmetic illustration, not an OpenTelemetry SDK benchmark. [2]
DGIM uses timestamped buckets for expiring stream counts. It is a different algorithm despite the shared name. Preserve units, temporality and window ownership separately from the histogram's scale.