Skip to main content

sum_or_avg

Function sum_or_avg 

Source
pub(crate) fn sum_or_avg(
    op: HistogramAggregate,
    histograms: impl IntoIterator<Item = Result<FloatHistogram>>,
) -> Result<(Option<FloatHistogram>, bool)>
Expand description

The Kahan sum or the mean of histograms in order, without compaction; None when there is none or they mix exponential and custom buckets. Prometheus sum_over_time and avg_over_time run the same steps as the aggregations. Histograms are consumed one at a time, so the first error ends the fold. The result is derived, so it carries no start timestamp.

The flag reports whether any add had to reconcile two different custom-bucket sets, which is what Prometheus annotates with an info. It is carried out of the fold rather than recomputed: the fold already calls FloatHistogram::kahan_add and receives that outcome.