vector/internal_events/
udp.rs1use metrics::counter;
2use vector_lib::internal_event::{
3 ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type,
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 datagram.";
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}
64
65#[derive(Debug)]
66pub struct UdpChunkingError {
67 pub error: vector_common::Error,
68 pub data_size: usize,
69}
70
71impl InternalEvent for UdpChunkingError {
72 fn emit(self) {
73 let reason = "Could not chunk UDP datagram.";
74 error!(
75 message = reason,
76 data_size = self.data_size,
77 error = self.error,
78 error_type = error_type::WRITER_FAILED,
79 stage = error_stage::SENDING,
80 internal_log_rate_limit = true,
81 );
82 counter!(
83 "component_errors_total",
84 "error_type" => error_type::WRITER_FAILED,
85 "stage" => error_stage::SENDING,
86 )
87 .increment(1);
88
89 emit!(ComponentEventsDropped::<UNINTENTIONAL> { count: 1, reason });
90 }
91}