vector_common/internal_event/
events_received.rs

1use metrics::{Counter, Histogram};
2
3use crate::{counter, histogram};
4use tracing::trace;
5
6use super::{CountByteSize, CounterName, HistogramName};
7
8crate::registered_event!(
9    EventsReceived => {
10        events_count: Histogram = histogram!(HistogramName::ComponentReceivedEventsCount),
11        events: Counter = counter!(CounterName::ComponentReceivedEventsTotal),
12        event_bytes: Counter = counter!(CounterName::ComponentReceivedEventBytesTotal),
13    }
14
15    fn emit(&self, data: CountByteSize) {
16        let CountByteSize(count, byte_size) = data;
17
18        trace!(message = "Events received.", count = %count, byte_size = %byte_size);
19
20        #[allow(clippy::cast_precision_loss)]
21        self.events_count.record(count as f64);
22        self.events.increment(count as u64);
23        self.event_bytes.increment(byte_size.get() as u64);
24    }
25);