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

enhancement: add new record_many method for histograms #531

Merged
merged 2 commits into from
Oct 12, 2024

Conversation

tobz
Copy link
Member

@tobz tobz commented Oct 12, 2024

Context

We've added a new method for recording to histograms: record_many. This is exposed on both Histogram and HistogramFn, with a default implementation provided on HistogramFn to make it backwards compatible.

It allows recording a single value multiple times, which can be a common use case when translating from bucketed histograms to histograms in metrics, as bucketed histograms may simply provide a single value for a bucket and the count of that value... so representing such a bucket in metrics requires recording that value count times.

Closes #509.

@tobz tobz added C-core Component: core functionality such as traits, etc. E-simple Effort: simple. T-enhancement Type: enhancement. labels Oct 12, 2024
@tobz tobz changed the title enhancement: add new method for histograms enhancement: add new record_many method for histograms Oct 12, 2024
@tobz tobz merged commit 81e6ee5 into main Oct 12, 2024
13 checks passed
@tobz tobz deleted the tobz/histogram-record-many branch October 12, 2024 18:00
@tobz tobz added the S-awaiting-release Status: awaiting a release to be considered fixed/implemented. label Oct 12, 2024
@0xdeafbeef
Copy link

But it still inefficiently burns CPU cycles:(

@tobz
Copy link
Member Author

tobz commented Oct 12, 2024

Yep, there's still work to do in order to actually have storage implementations provide an optimized implementation for it.

If you're interested in contributing a PR to add that support for AtomicBucket, I'm happy to try and guide you. The data structure isn't really designed to allow concurrently claiming multiple write slots in a bucket, but I do think it could be done.

@tobz
Copy link
Member Author

tobz commented Oct 12, 2024

Released as part of metrics@v0.24.0.

@tobz tobz removed the S-awaiting-release Status: awaiting a release to be considered fixed/implemented. label Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-core Component: core functionality such as traits, etc. E-simple Effort: simple. T-enhancement Type: enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add record_many to histogram
2 participants