Skip to content

Commit

Permalink
Global error handler cleanup - otel-proto (#2248)
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb authored Oct 27, 2024
1 parent 9e9b838 commit 4a405fd
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions opentelemetry-proto/src/transform/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub mod tonic {
use std::any::Any;
use std::fmt;

use opentelemetry::{global, metrics::MetricError, Key, Value};
use opentelemetry::{otel_debug, Key, Value};
use opentelemetry_sdk::metrics::data::{
self, Exemplar as SdkExemplar, ExponentialHistogram as SdkExponentialHistogram,
Gauge as SdkGauge, Histogram as SdkHistogram, Metric as SdkMetric,
Expand Down Expand Up @@ -97,10 +97,12 @@ pub mod tonic {
Temporality::Cumulative => AggregationTemporality::Cumulative,
Temporality::Delta => AggregationTemporality::Delta,
other => {
opentelemetry::global::handle_error(MetricError::Other(format!(
"Unknown temporality {:?}, using default instead.",
other
)));
otel_debug!(
name: "AggregationTemporality::Unknown",
message = "Unknown temporality,using default instead.",
unknown_temporality = format!("{:?}", other),
default_temporality = format!("{:?}", Temporality::Cumulative)
);
AggregationTemporality::Cumulative
}
}
Expand Down Expand Up @@ -184,7 +186,11 @@ pub mod tonic {
} else if let Some(gauge) = data.downcast_ref::<SdkGauge<f64>>() {
Ok(TonicMetricData::Gauge(gauge.into()))
} else {
global::handle_error(MetricError::Other("unknown aggregator".into()));
otel_debug!(
name: "TonicMetricData::UnknownAggregator",
message= "Unknown aggregator type",
unknown_type= format!("{:?}", data),
);
Err(())
}
}
Expand Down

0 comments on commit 4a405fd

Please sign in to comment.