client_java icon indicating copy to clipboard operation
client_java copied to clipboard

cumulativeness of classic histogram bucket counts

Open benjaminp opened this issue 9 months ago • 3 comments

ClassicHistogramBuckets' javadoc asserts that bucket counts are not cumulative. But, it seems in practice they are cumulative. Indeed, the only way classic histogram buckets can be cleared today is if the native histogram reset interval is configured. Cumulativeness is further consistent with the generic metric type documentation, which says that histogram buckets are cumulative.

benjaminp avatar Mar 06 '25 23:03 benjaminp

Internally, buckets are not cumulative - but that shouldn't be an issue. When scraping, they are cumulative.

zeitlinger avatar Apr 11 '25 14:04 zeitlinger

It occurred to me that with histograms there's two interpretations of the word "cumulative". There's the notion of cumulative in time. E.g., counters are cumulative in time because they're monotonic. With a histogram though, cumulative could also mean a higher bucket includes all counts in lower buckets. I.e., a cumulative histogram could mean the range of the buckets overlaps such that they bucket intervals are $[-\infty, b_1), [-\infty, b_2), [-\infty, b_3],\ldots$ rather than the disjoint $[-\infty, b_1), [b_1, b_2), [b_2, b_3),\ldots$. Do you think the ClassicHistogramBuckets javadoc is referring to this second notion of cumulativeness?

benjaminp avatar Apr 11 '25 23:04 benjaminp

.. to this second notion of cumulativeness?

that's correct - see https://en.wikipedia.org/wiki/Histogram#Cumulative_histogram and https://prometheus.io/docs/practices/histograms/#apdex-score

zeitlinger avatar Apr 14 '25 12:04 zeitlinger