vector/internal_events/
codecs.rs1use metrics::counter;
2use vector_lib::internal_event::{
3 ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type,
4};
5
6#[derive(Debug)]
7pub struct DecoderFramingError<E> {
8 pub error: E,
9}
10
11impl<E: std::fmt::Display> InternalEvent for DecoderFramingError<E> {
12 fn emit(self) {
13 error!(
14 message = "Failed framing bytes.",
15 error = %self.error,
16 error_code = "decoder_frame",
17 error_type = error_type::PARSER_FAILED,
18 stage = error_stage::PROCESSING,
19 );
20 counter!(
21 "component_errors_total",
22 "error_code" => "decoder_frame",
23 "error_type" => error_type::PARSER_FAILED,
24 "stage" => error_stage::PROCESSING,
25 )
26 .increment(1);
27 }
28}
29
30#[derive(Debug)]
31pub struct DecoderDeserializeError<'a> {
32 pub error: &'a crate::Error,
33}
34
35impl InternalEvent for DecoderDeserializeError<'_> {
36 fn emit(self) {
37 error!(
38 message = "Failed deserializing frame.",
39 error = %self.error,
40 error_code = "decoder_deserialize",
41 error_type = error_type::PARSER_FAILED,
42 stage = error_stage::PROCESSING,
43 );
44 counter!(
45 "component_errors_total",
46 "error_code" => "decoder_deserialize",
47 "error_type" => error_type::PARSER_FAILED,
48 "stage" => error_stage::PROCESSING,
49 )
50 .increment(1);
51 }
52}
53
54#[derive(Debug)]
55pub struct EncoderFramingError<'a> {
56 pub error: &'a vector_lib::codecs::encoding::BoxedFramingError,
57}
58
59impl InternalEvent for EncoderFramingError<'_> {
60 fn emit(self) {
61 let reason = "Failed framing bytes.";
62 error!(
63 message = reason,
64 error = %self.error,
65 error_code = "encoder_frame",
66 error_type = error_type::ENCODER_FAILED,
67 stage = error_stage::SENDING,
68 );
69 counter!(
70 "component_errors_total",
71 "error_code" => "encoder_frame",
72 "error_type" => error_type::ENCODER_FAILED,
73 "stage" => error_stage::SENDING,
74 )
75 .increment(1);
76 emit!(ComponentEventsDropped::<UNINTENTIONAL> { count: 1, reason });
77 }
78}
79
80#[derive(Debug)]
81pub struct EncoderSerializeError<'a> {
82 pub error: &'a crate::Error,
83}
84
85impl InternalEvent for EncoderSerializeError<'_> {
86 fn emit(self) {
87 let reason = "Failed serializing frame.";
88 error!(
89 message = reason,
90 error = %self.error,
91 error_code = "encoder_serialize",
92 error_type = error_type::ENCODER_FAILED,
93 stage = error_stage::SENDING,
94 );
95 counter!(
96 "component_errors_total",
97 "error_code" => "encoder_serialize",
98 "error_type" => error_type::ENCODER_FAILED,
99 "stage" => error_stage::SENDING,
100 )
101 .increment(1);
102 emit!(ComponentEventsDropped::<UNINTENTIONAL> { count: 1, reason });
103 }
104}
105
106#[derive(Debug)]
107pub struct EncoderWriteError<'a, E> {
108 pub error: &'a E,
109 pub count: usize,
110}
111
112impl<E: std::fmt::Display> InternalEvent for EncoderWriteError<'_, E> {
113 fn emit(self) {
114 let reason = "Failed writing bytes.";
115 error!(
116 message = reason,
117 error = %self.error,
118 error_type = error_type::IO_FAILED,
119 stage = error_stage::SENDING,
120 );
121 counter!(
122 "component_errors_total",
123 "error_type" => error_type::ENCODER_FAILED,
124 "stage" => error_stage::SENDING,
125 )
126 .increment(1);
127 if self.count > 0 {
128 emit!(ComponentEventsDropped::<UNINTENTIONAL> {
129 count: self.count,
130 reason,
131 });
132 }
133 }
134}