Skip to content

Commit 9ddba91

Browse files
committed
remove propagator error
1 parent 4c7bf58 commit 9ddba91

File tree

2 files changed

+15
-45
lines changed

2 files changed

+15
-45
lines changed

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_error,
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_error!(
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_error!(
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_error!(
139+
name: "BaggagePropagator.Extract.InvalidFormat",
140+
message = "Invalid baggage format",
141+
baggage_header = header_value);
141142
None
142143
}
143144
});

opentelemetry/src/propagation/mod.rs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -62,37 +62,6 @@ impl<S: std::hash::BuildHasher> Extractor for HashMap<String, String, S> {
6262
}
6363
}
6464

65-
/// Error when extracting or injecting context data(i.e propagating) across application boundaries.
66-
#[derive(Error, Debug)]
67-
#[error("Cannot {} from {}, {}", ops, message, propagator_name)]
68-
pub struct PropagationError {
69-
message: &'static str,
70-
// which propagator does this error comes from
71-
propagator_name: &'static str,
72-
// are we extracting or injecting information across application boundaries
73-
ops: &'static str,
74-
}
75-
76-
impl PropagationError {
77-
/// Error happens when extracting information
78-
pub fn extract(message: &'static str, propagator_name: &'static str) -> Self {
79-
PropagationError {
80-
message,
81-
propagator_name,
82-
ops: "extract",
83-
}
84-
}
85-
86-
/// Error happens when extracting information
87-
pub fn inject(message: &'static str, propagator_name: &'static str) -> Self {
88-
PropagationError {
89-
message,
90-
propagator_name,
91-
ops: "inject",
92-
}
93-
}
94-
}
95-
9665
#[cfg(test)]
9766
mod tests {
9867
use super::*;

0 commit comments

Comments
 (0)