Skip to content
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

Global error handler cleanup - Metrics View #2249

Merged
merged 8 commits into from
Oct 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions opentelemetry-sdk/src/metrics/view.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use super::instrument::{Instrument, Stream};
use glob::Pattern;
use opentelemetry::{
global,
metrics::{MetricError, MetricResult},
};
use opentelemetry::metrics::{MetricError, MetricResult};

fn empty_view(_inst: &Instrument) -> Option<Stream> {
None
Expand Down Expand Up @@ -102,19 +99,14 @@ impl View for Box<dyn View> {
/// ```
pub fn new_view(criteria: Instrument, mask: Stream) -> MetricResult<Box<dyn View>> {
if criteria.is_empty() {
global::handle_error(MetricError::Config(format!(
"no criteria provided, dropping view. mask: {mask:?}"
)));
// TODO - The error is getting lost here. Need to return or log.
return Ok(Box::new(empty_view));
}
let contains_wildcard = criteria.name.contains(['*', '?']);
let err_msg_criteria = criteria.clone();

let match_fn: Box<dyn Fn(&Instrument) -> bool + Send + Sync> = if contains_wildcard {
if mask.name != "" {
global::handle_error(MetricError::Config(format!(
"name replacement for multiple instruments, dropping view, criteria: {criteria:?}, mask: {mask:?}"
)));
// TODO - The error is getting lost here. Need to return or log.
return Ok(Box::new(empty_view));
}

Expand All @@ -137,11 +129,8 @@ pub fn new_view(criteria: Instrument, mask: Stream) -> MetricResult<Box<dyn View
if let Some(ma) = &mask.aggregation {
match ma.validate() {
Ok(_) => agg = Some(ma.clone()),
Err(err) => {
global::handle_error(MetricError::Other(format!(
"{}, proceeding as if view did not exist. criteria: {:?}, mask: {:?}",
err, err_msg_criteria, mask
)));
Err(_) => {
// TODO - The error is getting lost here. Need to return or log.
return Ok(Box::new(empty_view));
}
}
Expand Down
Loading