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

src/metrics/histogram.rs Document no default buckets #63

Merged
merged 4 commits into from
May 23, 2022

Conversation

doehyunbaek
Copy link
Contributor

As suggested and discussed in #61,
this commit adds a comment that describes unavailability of default
values for buckets.

I thought about providing test case that demonstrates using iterator for buckets as arguments. But thought that would be a bit overkill. If you think it would help let me know.

As suggested and discussed in prometheus#61,
this commit adds a comment that describes unavailability of default
values for buckets.

Signed-off-by: Doehyun Baek <doehyunbaek@gmail.com>
@mxinden
Copy link
Member

mxinden commented May 16, 2022

I thought about providing test case that demonstrates using iterator for buckets as arguments. But thought that would be a bit overkill. If you think it would help let me know.

I think a doc test showcasing the default values from the Go implementation, with a link to the Go code would be great.

src/metrics/histogram.rs Outdated Show resolved Hide resolved
Co-authored-by: Max Inden <mail@max-inden.de>
Signed-off-by: Doehyun Baek <doehyunbaek@gmail.com>
@doehyunbaek
Copy link
Contributor Author

Was a little sad I could not use array.into_iter() but used IntoIterator::into_iter(array) instead.

Thought about asserting with Histogram struct for doctest but seemed gnarly and settled for simple .observe() call as exponential_buckets example.

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

Could you wrap the lines?

@@ -9,6 +9,17 @@ use std::sync::{Arc, Mutex, MutexGuard};

/// Open Metrics [`Histogram`] to measure distributions of discrete events.
///
/// [`Histogram`] does not implement [`Default`], given that the choice of bucket values depends on the situation [`Histogram`] is used in. As an example, to measure HTTP request latency, the values suggested in the Golang implementation might work for you:
Copy link
Member

Choose a reason for hiding this comment

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

How about moving this section below the vanilla doc example (line 12 / 23)?

@mxinden
Copy link
Member

mxinden commented May 22, 2022

Was a little sad I could not use array.into_iter() but used IntoIterator::into_iter(array) instead.

Oh, haven't looked deeply into this. Shouldn't array.into_iter() work? Does type inference not work here?

https://doc.rust-lang.org/std/primitive.array.html#impl-IntoIterator

@doehyunbaek
Copy link
Contributor Author

doehyunbaek commented May 22, 2022

I should have explained more specifically.. Sorry for that.

Arrays have special behavior prior to 2021 edition.

If we use 2021 edition, array.into_iter would work, if not, we should resort to Intoiterator::into_iter(array) to iterate by value.

Signed-off-by: Doehyun Baek <doehyunbaek@gmail.com>
@doehyunbaek
Copy link
Contributor Author

Done!

@mxinden
Copy link
Member

mxinden commented May 23, 2022

I should have explained more specifically.. Sorry for that.

Arrays have special behavior prior to 2021 edition.

If we use 2021 edition, array.into_iter would work, if not, we should resort to Intoiterator::into_iter(array) to iterate by value.

Oh, right. Thanks for the links. Given that editions don't split the ecosystem what do you think of moving prometheus-client to edition 2021 in a separate pull request?

Sorry for derailing your initial proposal here. While not directly related, I think this is very valuable.

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

🙏 thank you for the help.

src/metrics/histogram.rs Outdated Show resolved Hide resolved
@doehyunbaek
Copy link
Contributor Author

Agreed. I will work on edition 2021 PR this week.

@mxinden mxinden merged commit 63f0a92 into prometheus:master May 23, 2022
ackintosh pushed a commit to ackintosh/client_rust that referenced this pull request Aug 27, 2022
As suggested and discussed in prometheus#61,
this commit adds a comment that describes unavailability of default
values for buckets.

Signed-off-by: Doehyun Baek <doehyunbaek@gmail.com>
Signed-off-by: ackintosh <sora.akatsuki@gmail.com>
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