Skip to content

Commit 53e892a

Browse files
authored
Nit fix by avoiding bound validation unless View feature is enabled (#2355)
1 parent 0e221c1 commit 53e892a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

opentelemetry-sdk/src/metrics/internal/histogram.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,15 @@ pub(crate) struct Histogram<T: Number> {
7474
}
7575

7676
impl<T: Number> Histogram<T> {
77+
#[allow(unused_mut)]
7778
pub(crate) fn new(mut bounds: Vec<f64>, record_min_max: bool, record_sum: bool) -> Self {
78-
bounds.retain(|v| !v.is_nan());
79-
bounds.sort_by(|a, b| a.partial_cmp(b).expect("NaNs filtered out"));
79+
#[cfg(feature = "spec_unstable_metrics_views")]
80+
{
81+
// TODO: When views are used, validate this upfront
82+
bounds.retain(|v| !v.is_nan());
83+
bounds.sort_by(|a, b| a.partial_cmp(b).expect("NaNs filtered out"));
84+
}
85+
8086
let buckets_count = bounds.len() + 1;
8187
Histogram {
8288
value_map: ValueMap::new(buckets_count),

0 commit comments

Comments
 (0)