vector_common/internal_event/
bytes_sent.rs

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