From 4a405fdfa28d6aeaa1cd302aafe5a6a680b9022c Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Sat, 26 Oct 2024 19:13:30 -0700 Subject: [PATCH] Global error handler cleanup - otel-proto (#2248) --- opentelemetry-proto/src/transform/metrics.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/opentelemetry-proto/src/transform/metrics.rs b/opentelemetry-proto/src/transform/metrics.rs index 66db88a1d4..df3e105803 100644 --- a/opentelemetry-proto/src/transform/metrics.rs +++ b/opentelemetry-proto/src/transform/metrics.rs @@ -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, @@ -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 } } @@ -184,7 +186,11 @@ pub mod tonic { } else if let Some(gauge) = data.downcast_ref::>() { 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(()) } }