Don't log a trace if EventWriter::send_batch is empty (#7753)

# Objective
Fix #5026.

## Solution
Only make a `trace!` log if the event count changed.

---

## Changelog
Changed: `EventWriter::send_batch` will only log a TRACE level log if the batch is non-empty.
This commit is contained in:
James Liu 2023-02-20 21:51:21 +00:00
parent 2a598d3e5a
commit 4e15d3d8bb

View file

@ -640,6 +640,7 @@ impl<E: Event> std::iter::Extend<E> for Events<E> {
where where
I: IntoIterator<Item = E>, I: IntoIterator<Item = E>,
{ {
let old_count = self.event_count;
let mut event_count = self.event_count; let mut event_count = self.event_count;
let events = iter.into_iter().map(|event| { let events = iter.into_iter().map(|event| {
let event_id = EventId { let event_id = EventId {
@ -652,11 +653,14 @@ impl<E: Event> std::iter::Extend<E> for Events<E> {
self.events_b.extend(events); self.events_b.extend(events);
if old_count != event_count {
trace!( trace!(
"Events::extend() -> ids: ({}..{})", "Events::extend() -> ids: ({}..{})",
self.event_count, self.event_count,
event_count event_count
); );
}
self.event_count = event_count; self.event_count = event_count;
} }
} }