Skip to content

Commit

Permalink
Rename Event.filter -> is_filtered
Browse files Browse the repository at this point in the history
  • Loading branch information
hillu committed Jan 2, 2025
1 parent 7665846 commit 7e7f42d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/bin/laurel/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ fn run_app() -> Result<(), anyhow::Error> {
let mut filter_logger =
Logger::new(&config.filterlog, &dir).context("can't create filterlog logger")?;
emit_fn_log = move |e: &Event| {
if e.filter {
if e.is_filtered {
filter_logger
.log(e)
.map_err(|e| anyhow!("Error writing to filter log: {e}"))
Expand All @@ -321,7 +321,7 @@ fn run_app() -> Result<(), anyhow::Error> {
} else {
log::info!("Dropping filtered audit records");
emit_fn_drop = move |e: &Event| {
if !e.filter {
if !e.is_filtered {
logger
.log(e)
.map_err(|e| anyhow!("Error writing to audit log: {e}"))
Expand Down
20 changes: 10 additions & 10 deletions src/coalesce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ impl<'a, 'ev> Coalesce<'a, 'ev> {
_ => {
// first syscall in new process
if !self.settings.filter_first_per_process {
ev.filter = false;
ev.is_filtered = false;
force_keep = true;
}
proc.key = ProcessKey::Event(ev.id);
Expand Down Expand Up @@ -863,13 +863,13 @@ impl<'a, 'ev> Coalesce<'a, 'ev> {

if let Some(key) = &key {
if !force_keep && self.settings.filter_keys.contains(key.as_ref()) {
ev.filter = true;
ev.is_filtered = true;
}
if self.settings.proc_label_keys.contains(key.as_ref()) {
proc.labels.insert(key.to_vec());
}
} else if !force_keep && self.settings.filter_null_keys {
ev.filter = true;
ev.is_filtered = true;
}

current_process = Some(proc);
Expand Down Expand Up @@ -933,11 +933,11 @@ impl<'a, 'ev> Coalesce<'a, 'ev> {
.iter()
.any(|x| self.settings.filter_labels.contains(x))
{
ev.filter = true;
ev.is_filtered = true;
}
}

if ev.filter {
if ev.is_filtered {
return;
}

Expand Down Expand Up @@ -989,7 +989,7 @@ impl<'a, 'ev> Coalesce<'a, 'ev> {
/// event is emitted only when an EOE ("end of event") line for
/// the event is encountered.
pub fn process_line(&mut self, line: &[u8]) -> Result<(), CoalesceError> {
let filter_raw = self.settings.filter_raw_lines.is_match(line);
let do_filter = self.settings.filter_raw_lines.is_match(line);

let skip_enriched = self.settings.translate_universal && self.settings.translate_userdb;
let msg = parse(line, skip_enriched).map_err(CoalesceError::Parse)?;
Expand Down Expand Up @@ -1023,7 +1023,7 @@ impl<'a, 'ev> Coalesce<'a, 'ev> {
.insert(nid.clone(), Event::new(msg.node, msg.id));
}
let ev = self.inflight.get_mut(&nid).unwrap();
ev.filter |= filter_raw;
ev.is_filtered |= do_filter;
match ev.body.get_mut(&msg.ty) {
Some(EventValues::Single(v)) => v.extend(msg.body),
Some(EventValues::Multi(v)) => v.push(msg.body),
Expand All @@ -1045,7 +1045,7 @@ impl<'a, 'ev> Coalesce<'a, 'ev> {
return Err(CoalesceError::DuplicateEvent(msg.id));
}
let mut ev = Event::new(msg.node, msg.id);
ev.filter |= filter_raw;
ev.is_filtered |= do_filter;
ev.body.insert(msg.ty, EventValues::Single(msg.body));
self.emit_event(ev);
}
Expand Down Expand Up @@ -1501,7 +1501,7 @@ mod test {
ec: &'c Rc<RefCell<Option<Event<'ev>>>>,
) -> impl FnMut(&Event<'ev>) + 'c {
|ev: &Event| {
if !ev.filter {
if !ev.is_filtered {
*ec.borrow_mut() = Some(ev.clone());
}
}
Expand All @@ -1510,7 +1510,7 @@ mod test {
// Returns an emitter function that appends the event onto a Vec
fn mk_emit_vec<'c, 'ev>(ec: &'c Rc<RefCell<Vec<Event<'ev>>>>) -> impl FnMut(&Event<'ev>) + 'c {
|ev: &Event| {
if !ev.filter {
if !ev.is_filtered {
ec.borrow_mut().push(ev.clone());
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub struct Event<'a> {
pub id: EventID,
pub body: IndexMap<MessageType, EventValues<'a>>,
pub container_info: Option<Body<'a>>,
pub filter: bool,
pub is_filtered: bool,
}

impl Event<'_> {
Expand All @@ -50,7 +50,7 @@ impl Event<'_> {
id,
body: IndexMap::with_capacity(5),
container_info: None,
filter: false,
is_filtered: false,
}
}
}
Expand Down

0 comments on commit 7e7f42d

Please sign in to comment.