vector_common/internal_event/
bytes_received.rs

1use metrics::{counter, Counter};
2
3use super::{ByteSize, Protocol, SharedString};
4
5crate::registered_event!(
6    BytesReceived {
7        protocol: SharedString,
8    } => {
9        received_bytes: Counter = counter!("component_received_bytes_total", "protocol" => self.protocol.clone()),
10        protocol: SharedString = self.protocol,
11    }
12
13    fn emit(&self, data: ByteSize) {
14        self.received_bytes.increment(data.0 as u64);
15        trace!(message = "Bytes received.", byte_size = %data.0, protocol = %self.protocol);
16    }
17);
18
19impl From<Protocol> for BytesReceived {
20    fn from(protocol: Protocol) -> Self {
21        Self {
22            protocol: protocol.0,
23        }
24    }
25}