Skip to content

Commit

Permalink
Nit fix by avoiding bound validation unless View feature is enabled (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cijothomas authored Nov 27, 2024
1 parent 0e221c1 commit 53e892a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions opentelemetry-sdk/src/metrics/internal/histogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,15 @@ pub(crate) struct Histogram<T: Number> {
}

impl<T: Number> Histogram<T> {
#[allow(unused_mut)]
pub(crate) fn new(mut bounds: Vec<f64>, record_min_max: bool, record_sum: bool) -> Self {
bounds.retain(|v| !v.is_nan());
bounds.sort_by(|a, b| a.partial_cmp(b).expect("NaNs filtered out"));
#[cfg(feature = "spec_unstable_metrics_views")]
{
// TODO: When views are used, validate this upfront
bounds.retain(|v| !v.is_nan());
bounds.sort_by(|a, b| a.partial_cmp(b).expect("NaNs filtered out"));
}

let buckets_count = bounds.len() + 1;
Histogram {
value_map: ValueMap::new(buckets_count),
Expand Down

0 comments on commit 53e892a

Please sign in to comment.