diff --git a/opentelemetry-sdk/src/metrics/internal/histogram.rs b/opentelemetry-sdk/src/metrics/internal/histogram.rs index f4690850a3..ac4a6806b7 100644 --- a/opentelemetry-sdk/src/metrics/internal/histogram.rs +++ b/opentelemetry-sdk/src/metrics/internal/histogram.rs @@ -74,9 +74,15 @@ pub(crate) struct Histogram { } impl Histogram { + #[allow(unused_mut)] pub(crate) fn new(mut bounds: Vec, 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),