Skip to content

Commit

Permalink
Add comments re dropping and then readding fields
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com>
  • Loading branch information
StephenWakely committed Jul 17, 2023
1 parent 553223d commit cd7a4f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/vector-core/src/event/log_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ impl LogEvent {
}
}

/// Retrieves the value of a field based on it's meaning.
/// This will first check if the value has previously been dropped. It is worth being
/// aware that if the field has been dropped and then some how readded, we still fetch
/// the dropped value here.
pub fn get_by_meaning(&self, meaning: impl AsRef<str>) -> Option<&Value> {
if let Some(dropped) = self.metadata().dropped_field(&meaning) {
Some(dropped)
Expand Down
3 changes: 3 additions & 0 deletions lib/vector-core/src/event/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ impl EventMetadata {
}

/// Adds the value to the dropped fields list.
/// There is currently no way to remove a field from this list, so if a field is dropped
/// and then the field is re-added with a new value - the dropped value will still be
/// retrieved.
pub fn add_dropped_field(&mut self, meaning: String, value: Value) {
self.dropped_fields.insert(meaning, value);
}
Expand Down

0 comments on commit cd7a4f8

Please sign in to comment.