Skip to content

Commit b7380da

Browse files
committed
Nit fix by avoiding bound validation unless View feature is enabled
1 parent 0e221c1 commit b7380da

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,13 @@ pub(crate) struct Histogram<T: Number> {
7575

7676
impl<T: Number> Histogram<T> {
7777
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"));
78+
#[cfg(feature = "spec_unstable_metrics_views")]
79+
{
80+
// TODO: When views are used, validate this upfront
81+
bounds.retain(|v| !v.is_nan());
82+
bounds.sort_by(|a, b| a.partial_cmp(b).expect("NaNs filtered out"));
83+
}
84+
8085
let buckets_count = bounds.len() + 1;
8186
Histogram {
8287
value_map: ValueMap::new(buckets_count),

0 commit comments

Comments
 (0)