Skip to content

Commit 01e4f4d

Browse files
authored
Merge branch 'main' into refactor/metric-exporters-non-plural
2 parents c1d2f0f + 4a405fd commit 01e4f4d

File tree

3 files changed

+32
-36
lines changed

3 files changed

+32
-36
lines changed

opentelemetry-proto/src/transform/metrics.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub mod tonic {
88
use std::any::Any;
99
use std::fmt;
1010

11-
use opentelemetry::{global, metrics::MetricError, Key, Value};
11+
use opentelemetry::{otel_debug, Key, Value};
1212
use opentelemetry_sdk::metrics::data::{
1313
self, Exemplar as SdkExemplar, ExponentialHistogram as SdkExponentialHistogram,
1414
Gauge as SdkGauge, Histogram as SdkHistogram, Metric as SdkMetric,
@@ -97,10 +97,12 @@ pub mod tonic {
9797
Temporality::Cumulative => AggregationTemporality::Cumulative,
9898
Temporality::Delta => AggregationTemporality::Delta,
9999
other => {
100-
opentelemetry::global::handle_error(MetricError::Other(format!(
101-
"Unknown temporality {:?}, using default instead.",
102-
other
103-
)));
100+
otel_debug!(
101+
name: "AggregationTemporality::Unknown",
102+
message = "Unknown temporality,using default instead.",
103+
unknown_temporality = format!("{:?}", other),
104+
default_temporality = format!("{:?}", Temporality::Cumulative)
105+
);
104106
AggregationTemporality::Cumulative
105107
}
106108
}
@@ -184,7 +186,11 @@ pub mod tonic {
184186
} else if let Some(gauge) = data.downcast_ref::<SdkGauge<f64>>() {
185187
Ok(TonicMetricData::Gauge(gauge.into()))
186188
} else {
187-
global::handle_error(MetricError::Other("unknown aggregator".into()));
189+
otel_debug!(
190+
name: "TonicMetricData::UnknownAggregator",
191+
message= "Unknown aggregator type",
192+
unknown_type= format!("{:?}", data),
193+
);
188194
Err(())
189195
}
190196
}

opentelemetry-sdk/src/metrics/view.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
use super::instrument::{Instrument, Stream};
22
use glob::Pattern;
3-
use opentelemetry::{
4-
global,
5-
metrics::{MetricError, MetricResult},
6-
};
3+
use opentelemetry::metrics::{MetricError, MetricResult};
74

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

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

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

opentelemetry-sdk/src/propagation/baggage.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use once_cell::sync::Lazy;
2-
use opentelemetry::propagation::PropagationError;
32
use opentelemetry::{
43
baggage::{BaggageExt, KeyValueMetadata},
5-
global,
4+
otel_warn,
65
propagation::{text_map_propagator::FieldIter, Extractor, Injector, TextMapPropagator},
76
Context,
87
};
@@ -120,24 +119,26 @@ impl TextMapPropagator for BaggagePropagator {
120119
decoded_props.as_str(),
121120
))
122121
} else {
123-
global::handle_error(PropagationError::extract(
124-
"invalid UTF8 string in key values",
125-
"BaggagePropagator",
126-
));
122+
otel_warn!(
123+
name: "BaggagePropagator.Extract.InvalidUTF8",
124+
message = "Invalid UTF8 string in key values",
125+
baggage_header = header_value,
126+
);
127127
None
128128
}
129129
} else {
130-
global::handle_error(PropagationError::extract(
131-
"invalid baggage key-value format",
132-
"BaggagePropagator",
133-
));
130+
otel_warn!(
131+
name: "BaggagePropagator.Extract.InvalidKeyValueFormat",
132+
message = "Invalid baggage key-value format",
133+
baggage_header = header_value,
134+
);
134135
None
135136
}
136137
} else {
137-
global::handle_error(PropagationError::extract(
138-
"invalid baggage format",
139-
"BaggagePropagator",
140-
));
138+
otel_warn!(
139+
name: "BaggagePropagator.Extract.InvalidFormat",
140+
message = "Invalid baggage format",
141+
baggage_header = header_value);
141142
None
142143
}
143144
});

0 commit comments

Comments
 (0)