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

add native histogram exemplar support #1471

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fatsheep9146
Copy link

fix #1126

@beorn7 beorn7 self-requested a review March 15, 2024 08:56
Copy link
Member

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

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

not a native histogram expert here, just some small comments :)

prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram_test.go Outdated Show resolved Hide resolved
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.

Thanks for doing this. I think this implements the correct algorithm, but there is the huge problem of concurrency. See comments. A also think a more basic approach with a single slice rather than two linked list and a map will be faster in practice and consume less memory. Also see comments.

prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
@beorn7
Copy link
Member

beorn7 commented Apr 3, 2024

I'll try to get to this ASAP, but currently, I'm sick.

@fatsheep9146
Copy link
Author

I'll try to get to this ASAP, but currently, I'm sick.

Thanks! Please take good care of yourself and rest well, there is no rush

Copy link
Member

@kakkoyun kakkoyun left a comment

Choose a reason for hiding this comment

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

Nice to have this. Thanks for the contribution 🎉

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.

Thanks a lot. I finally have done a detailed review. Things are a bit tricky, but I hope I have explained it well enough.

In different news, the doc comment for the ExemplarObserver interface (in file observer.go) needs an update, explaining broadly the behavior for native histograms, which should also include a warning that ObserveWithExemplar isn't lock-free if called on a native histogram with configured exemplars so that it should not be called too frequently.

prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
@fatsheep9146
Copy link
Author

@beorn7 The pr is ready for review again.

@beorn7
Copy link
Member

beorn7 commented Apr 23, 2024

Thank you very much. I'm on vacation this week, but this is high on my list once I'm back in action.

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.

Very cool.

I think all that remains is wordsmithing and some formatting tweaks. See all my pedantic comments. :)

prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
prometheus/histogram.go Outdated Show resolved Hide resolved
@fatsheep9146
Copy link
Author

@beorn7
The commit history seems too long, I can squash to one commit if you think there are no more changes needed.

@beorn7
Copy link
Member

beorn7 commented May 8, 2024

No worries, I can just squash during merge.

Or, if you like a more detailed commit structure with more than one commit, but not the 20 we have now, you could rebase on your own.

@beorn7
Copy link
Member

beorn7 commented May 8, 2024

One thing fell through the cracks: The doc comment to the ObserveWithExemplar method in histogram.go should contain a warning that it isn't lock-free for native histograms with configured exemplars and therefore should not be called in high-frequency settings.

@beorn7
Copy link
Member

beorn7 commented May 8, 2024

Otherwise, this looks good. I'll give @ArthurSens @bwplotka and @kakkoyun a few more days to raise objections.

Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
@fatsheep9146
Copy link
Author

@beorn7 I only kept two commits, one for first implementation, the other for reconstitution that you suggested in #1471 (comment)

@fatsheep9146 fatsheep9146 requested a review from kakkoyun May 8, 2024 23:24
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.

histograms: Support exemplars in pure Native Histograms
4 participants