Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions opentelemetry-sdk/src/propagation/baggage.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use once_cell::sync::Lazy;
use opentelemetry::propagation::PropagationError;
use opentelemetry::{
baggage::{BaggageExt, KeyValueMetadata},
global,
otel_error,
propagation::{text_map_propagator::FieldIter, Extractor, Injector, TextMapPropagator},
Context,
};
Expand Down Expand Up @@ -120,24 +119,26 @@ impl TextMapPropagator for BaggagePropagator {
decoded_props.as_str(),
))
} else {
global::handle_error(PropagationError::extract(
"invalid UTF8 string in key values",
"BaggagePropagator",
));
otel_error!(
name: "BaggagePropagator.Extract.InvalidUTF8",
message = "Invalid UTF8 string in key values",
baggage_header = header_value,
);
None
}
} else {
global::handle_error(PropagationError::extract(
"invalid baggage key-value format",
"BaggagePropagator",
));
otel_error!(
name: "BaggagePropagator.Extract.InvalidKeyValueFormat",
message = "Invalid baggage key-value format",
baggage_header = header_value,
);
None
}
} else {
global::handle_error(PropagationError::extract(
"invalid baggage format",
"BaggagePropagator",
));
otel_error!(
name: "BaggagePropagator.Extract.InvalidFormat",
message = "Invalid baggage format",
baggage_header = header_value);
None
}
});
Expand Down
31 changes: 0 additions & 31 deletions opentelemetry/src/propagation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,37 +62,6 @@ impl<S: std::hash::BuildHasher> Extractor for HashMap<String, String, S> {
}
}

/// Error when extracting or injecting context data(i.e propagating) across application boundaries.
#[derive(Error, Debug)]
#[error("Cannot {} from {}, {}", ops, message, propagator_name)]
pub struct PropagationError {
message: &'static str,
// which propagator does this error comes from
propagator_name: &'static str,
// are we extracting or injecting information across application boundaries
ops: &'static str,
}

impl PropagationError {
/// Error happens when extracting information
pub fn extract(message: &'static str, propagator_name: &'static str) -> Self {
PropagationError {
message,
propagator_name,
ops: "extract",
}
}

/// Error happens when extracting information
pub fn inject(message: &'static str, propagator_name: &'static str) -> Self {
PropagationError {
message,
propagator_name,
ops: "inject",
}
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
Loading