vector/internal_events/
udp.rs1use metrics::counter;
2use vector_lib::internal_event::{
3 error_stage, error_type, ComponentEventsDropped, InternalEvent, UNINTENTIONAL,
4};
5
6use crate::internal_events::SocketOutgoingConnectionError;
7
8#[derive(Debug)]
11pub struct UdpSocketConnectionEstablished;
12
13impl InternalEvent for UdpSocketConnectionEstablished {
14 fn emit(self) {
15 debug!(message = "Connected.");
16 counter!("connection_established_total", "mode" => "udp").increment(1);
17 }
18}
19
20pub struct UdpSocketOutgoingConnectionError<E> {
23 pub error: E,
24}
25
26impl<E: std::error::Error> InternalEvent for UdpSocketOutgoingConnectionError<E> {
27 fn emit(self) {
28 emit!(SocketOutgoingConnectionError { error: self.error });
31 }
32}
33
34#[derive(Debug)]
35pub struct UdpSendIncompleteError {
36 pub data_size: usize,
37 pub sent: usize,
38}
39
40impl InternalEvent for UdpSendIncompleteError {
41 fn emit(self) {
42 let reason = "Could not send all data in one UDP packet.";
43 error!(
44 message = reason,
45 data_size = self.data_size,
46 sent = self.sent,
47 dropped = self.data_size - self.sent,
48 error_type = error_type::WRITER_FAILED,
49 stage = error_stage::SENDING,
50 internal_log_rate_limit = true,
51 );
52 counter!(
53 "component_errors_total",
54 "error_type" => error_type::WRITER_FAILED,
55 "stage" => error_stage::SENDING,
56 )
57 .increment(1);
58 counter!("connection_send_errors_total", "mode" => "udp").increment(1);
60
61 emit!(ComponentEventsDropped::<UNINTENTIONAL> { count: 1, reason });
62 }
63}