1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use metrics::{counter, histogram, Counter, Histogram};
use tracing::trace;

use super::CountByteSize;

crate::registered_event!(
    EventsReceived => {
        events_count: Histogram = histogram!("component_received_events_count"),
        events: Counter = counter!("component_received_events_total"),
        event_bytes: Counter = counter!("component_received_event_bytes_total"),
    }

    fn emit(&self, data: CountByteSize) {
        let CountByteSize(count, byte_size) = data;

        trace!(message = "Events received.", count = %count, byte_size = %byte_size);

        #[allow(clippy::cast_precision_loss)]
        self.events_count.record(count as f64);
        self.events.increment(count as u64);
        self.event_bytes.increment(byte_size.get() as u64);
    }
);