Skip to content

Histogram spec: Rework and amend operators section#2823

Open
beorn7 wants to merge 1 commit intomainfrom
beorn7/histogram
Open

Histogram spec: Rework and amend operators section#2823
beorn7 wants to merge 1 commit intomainfrom
beorn7/histogram

Conversation

@beorn7
Copy link
Member

@beorn7 beorn7 commented Feb 4, 2026

  • Divide operators section into sub-sections and reformat accordingly.

  • Add that negative results of multiplication count as gauge histogram.

  • Correct and complete the sub-section about trim operators.

@beorn7
Copy link
Member Author

beorn7 commented Feb 18, 2026

Now that we have nailed down what to do in prometheus/prometheus#17904 , we can finalize this. @krajorama & @linasm what do you think about this? I'm wondering how detailed we should describe the edge cases in the spec (or pseudo-spec, as I prefer to call it) here. One could argue that they are all implied with the current wording, but another line of argument would say we should spell out the edge cases here explicitly. (I currently tend towards the former, as it is more in line with the other parts of this document.)

@beorn7
Copy link
Member Author

beorn7 commented Feb 24, 2026

As per discussion over on prometheus/prometheus#17904, I'll add a detailed edge case description here (hopefully tomorrow).

- Divide operators section into sub-sections and reformat accordingly.

- Add that negative results of multiplication count as gauge
  histogram.

- Improve and complete the sub-section about interpolation.

- Correct and complete the sub-section about trim operators.

Signed-off-by: beorn7 <beorn@grafana.com>
@beorn7
Copy link
Member Author

beorn7 commented Feb 25, 2026

I think the current version should cover all edge cases.

@krajorama @linasm please verify.

Copy link
Member

@krajorama krajorama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good over all, made two suggestions

Comment on lines +1885 to +1886
their flavor is left unchanged by the operation, with the exception that a
negative histogram is always considered to be a gauge histogram.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we check for negative value, so maybe

Suggested change
their flavor is left unchanged by the operation, with the exception that a
negative histogram is always considered to be a gauge histogram.
their flavor is left unchanged by the operation, with the exception that
multiplying by a negative value always results in a gauge histogram.

Comment on lines +1973 to +1975
deliberately simple to make it easier to reason with. In general, the
histograms resulting from trim operations are meant to be used for quantile
estimation. Their sum of observations is considered to be of limited use.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to get my use case in here, because I think it's particularly useful.

I'm suggesting the following, but this buries "Their sum of observations is considered to be of limited use." a little bit, so needs some work:

Suggested change
deliberately simple to make it easier to reason with. In general, the
histograms resulting from trim operations are meant to be used for quantile
estimation. Their sum of observations is considered to be of limited use.
deliberately simple to make it easier to reason with.
Their sum of observations is considered to be of limited use.
In general, the histograms resulting from trim operations are
meant to be used for quantile estimation or filtering. The trim
operator can be a good replacement of `histogram_fraction` in
cases when one boundary is infinite, such as calculating number
of observations below a certain threshold for an alert.
For example using `histogram_count(h </ x)` instead of
`histogram_fraction(-Inf, x, h) * histogram_count(h)` is simpler
and also yields `0` instead of `NaN` in case `h` has no observations,
because the fraction would divide 0 by 0 in the later case.

Or we can flip it around and just mention this case here and elaborate in histogram_fraction ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants