Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

histogram: get sample count after distinguishing classic and native #176

Merged
merged 2 commits into from
Jul 11, 2024

Conversation

jan--f
Copy link
Contributor

@jan--f jan--f commented Jul 11, 2024

GetSampleCount returns 0 for float histograms.

`GetSampleCount` returns 0 for float histograms.

Signed-off-by: Jan Fajerski <jfajersk@redhat.com>
@jan--f jan--f requested a review from beorn7 July 11, 2024 09:48
@beorn7 beorn7 mentioned this pull request Jul 11, 2024
Copy link
Member

@beorn7 beorn7 left a comment

Choose a reason for hiding this comment

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

Good catch.

However, even classic histograms can be float histograms (which is a relatively new addition to the protobuf spec, so prom2json wasn't aware of this so far).

See my comment how to fix count, but we also have to fix makeBuckets and let it try GetCumulativeCountFloat first.

@@ -112,7 +112,6 @@ func makeHistogram(m *dto.Metric) Histogram {
hist := Histogram{
Labels: makeLabels(m),
TimestampMs: makeTimestamp(m),
Count: fmt.Sprint(dtoH.GetSampleCount()),
Copy link
Member

Choose a reason for hiding this comment

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

Even classic histograms can be float histograms, so we need to treat this differently for both classic and native histograms.

So what we have to do is to first check dtoH.GetSampleCountFloat(). If that's > 0, take it. Otherwise, take dtoH.GetSampleCount().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ahh I didn't know that. I guess we need the same in pushgateway too :)

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, although I think it will never really happen that somebody pushes a classic float histogram to the PGW. But yes, in principle, we want that in the PGW, too.

Signed-off-by: Jan Fajerski <jfajersk@redhat.com>
@jan--f jan--f requested a review from beorn7 July 11, 2024 11:56
Copy link
Member

@beorn7 beorn7 left a comment

Choose a reason for hiding this comment

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

Nice, thank you.

@beorn7 beorn7 merged commit 48e4461 into prometheus:master Jul 11, 2024
4 checks passed
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.

None yet

2 participants