-
Notifications
You must be signed in to change notification settings - Fork 525
fix: Fix validation in Metric stream #2991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Fix validation in Metric stream #2991
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2991 +/- ##
======================================
Coverage 81.4% 81.5%
======================================
Files 126 126
Lines 24573 24796 +223
======================================
+ Hits 20008 20213 +205
- Misses 4565 4583 +18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
result.err() | ||
); | ||
} else { | ||
let err = result.err().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: You could use unwrap_err()
and possibly even get rid of the err.to_string()
check below.
let err = result.err().unwrap(); | |
let err = result.unwrap_err(); |
if let Some(limit) = self.cardinality_limit { | ||
if limit == 0 { | ||
return Err("Cardinality limit must be greater than 0".into()); | ||
} | ||
} | ||
|
||
// If the aggregation is set to ExplicitBucketHistogram, validate the bucket boundaries. | ||
// Validate bucket boundaries if using ExplicitBucketHistogram |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we are doing the validation while building the stream, we could get rid of this code:
opentelemetry-rust/opentelemetry-sdk/src/metrics/internal/histogram.rs
Lines 95 to 100 in 8c29ca7
#[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")); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, will tackle it soon.
Most copy-pasted from instrument creation validation for now. A future refactor can move this to a common place and fully address #2986