Skip to content

Commit

Permalink
src/metrics/histogram.rs: Document no default buckets (#63)
Browse files Browse the repository at this point in the history
As suggested and discussed in #61,
this commit adds a comment that describes unavailability of default
values for buckets.

Signed-off-by: Doehyun Baek <doehyunbaek@gmail.com>
  • Loading branch information
doehyunbaek authored May 23, 2022
1 parent abdcfb1 commit 63f0a92
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/metrics/histogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ use std::sync::{Arc, Mutex, MutexGuard};
/// let histogram = Histogram::new(exponential_buckets(1.0, 2.0, 10));
/// histogram.observe(4.2);
/// ```
///
/// [`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:
///
/// ```
/// # use prometheus_client::metrics::histogram::Histogram;
/// // Default values from go client(https://github.com/prometheus/client_golang/blob/5d584e2717ef525673736d72cd1d12e304f243d7/prometheus/histogram.go#L68)
/// let histogram = Histogram::new(IntoIterator::into_iter([
/// 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0,
/// ]));
/// histogram.observe(4.2);
/// ```
// TODO: Consider using atomics. See
// https://github.com/tikv/rust-prometheus/pull/314.
pub struct Histogram {
Expand Down

0 comments on commit 63f0a92

Please sign in to comment.