vector_common/internal_event/
bytes_received.rs

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