Skip to content

Commit 728f61b

Browse files
authored
Merge branch 'main' into sync-instrument-internal-log
2 parents b193461 + 3bc9b3d commit 728f61b

File tree

3 files changed

+36
-27
lines changed

3 files changed

+36
-27
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/pipeline.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ use std::{
66
};
77

88
use opentelemetry::{
9-
global,
109
metrics::{MetricError, MetricResult},
11-
InstrumentationScope, KeyValue,
10+
otel_debug, InstrumentationScope, KeyValue,
1211
};
1312

1413
use crate::{
@@ -413,15 +412,18 @@ where
413412
if existing == id {
414413
return;
415414
}
416-
417-
global::handle_error(MetricError::Other(format!(
418-
"duplicate metric stream definitions, names: ({} and {}), descriptions: ({} and {}), kinds: ({:?} and {:?}), units: ({:?} and {:?}), and numbers: ({} and {})",
415+
// If an existing instrument with the same name but different attributes is found,
416+
// log a warning with details about the conflicting metric stream definitions.
417+
otel_debug!(
418+
name: "Instrument.DuplicateMetricStreamDefinitions",
419+
message = "duplicate metric stream definitions",
420+
reason = format!("names: ({} and {}), descriptions: ({} and {}), kinds: ({:?} and {:?}), units: ({:?} and {:?}), and numbers: ({} and {})",
419421
existing.name, id.name,
420422
existing.description, id.description,
421423
existing.kind, id.kind,
422424
existing.unit, id.unit,
423-
existing.number, id.number,
424-
)))
425+
existing.number, id.number,)
426+
);
425427
}
426428
}
427429
}

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)