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