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

refactor(metrics/histogram): 🎂 constructor accepts IntoIterator #243

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.24.0] - unreleased
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
## [0.24.0] - unreleased
## [0.23.1]

Not a breaking change.

Also, if you bump the version in Cargo.toml to v0.24.1 I am happy to cut a patch release right away.


- `Histogram::new` now accepts an `IntoIterator` argument, rather than an `Iterator`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- `Histogram::new` now accepts an `IntoIterator` argument, rather than an `Iterator`.
### Added
- `Histogram::new` now accepts an `IntoIterator` argument, rather than an `Iterator`.

See keepachangelog format.

See [PR 243].

[PR 243]: https://github.com/prometheus/client_rust/pull/243

## [0.23.0]

### Changed
Expand Down
9 changes: 7 additions & 2 deletions src/metrics/histogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use std::sync::Arc;
/// let custom_buckets = [
/// 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0,
/// ];
/// let histogram = Histogram::new(custom_buckets.into_iter());
/// let histogram = Histogram::new(custom_buckets);
/// histogram.observe(4.2);
/// ```
// TODO: Consider using atomics. See
Expand Down Expand Up @@ -57,7 +57,12 @@ pub(crate) struct Inner {

impl Histogram {
/// Create a new [`Histogram`].
pub fn new(buckets: impl Iterator<Item = f64>) -> Self {
///
/// ```rust
/// # use prometheus_client::metrics::histogram::Histogram;
/// let histogram = Histogram::new([10.0, 100.0, 1_000.0]);
/// ```
pub fn new(buckets: impl IntoIterator<Item = f64>) -> Self {
Self {
inner: Arc::new(RwLock::new(Inner {
sum: Default::default(),
Expand Down
Loading