Skip to content

Commit

Permalink
bring back PropagationError, will cleanup separately
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb committed Oct 26, 2024
1 parent 0f126be commit f83c1dd
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions opentelemetry/src/propagation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,37 @@ 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

0 comments on commit f83c1dd

Please sign in to comment.