vector/internal_events/
encoding_transcode.rs

1use metrics::counter;
2use vector_lib::internal_event::InternalEvent;
3
4#[derive(Debug)]
5pub struct DecoderBomRemoval {
6    pub from_encoding: &'static str,
7}
8
9impl InternalEvent for DecoderBomRemoval {
10    fn emit(self) {
11        trace!(
12            message = "Removing initial BOM bytes from the final output while decoding to utf8.",
13            from_encoding = %self.from_encoding,
14            internal_log_rate_limit = true
15        );
16        counter!("decoder_bom_removals_total").increment(1);
17    }
18}
19
20#[derive(Debug)]
21pub struct DecoderMalformedReplacement {
22    pub from_encoding: &'static str,
23}
24
25impl InternalEvent for DecoderMalformedReplacement {
26    fn emit(self) {
27        warn!(
28            message = "Replaced malformed sequences with replacement character while decoding to utf8.",
29            from_encoding = %self.from_encoding,
30            internal_log_rate_limit = true
31        );
32        // NOT the actual number of replacements in the output: there's no easy
33        // way to get that from the lib we use here (encoding_rs)
34        counter!("decoder_malformed_replacement_warnings_total").increment(1);
35    }
36}
37
38#[derive(Debug)]
39pub struct EncoderUnmappableReplacement {
40    pub to_encoding: &'static str,
41}
42
43impl InternalEvent for EncoderUnmappableReplacement {
44    fn emit(self) {
45        warn!(
46            message = "Replaced unmappable characters with numeric character references while encoding from utf8.",
47            to_encoding = %self.to_encoding,
48            internal_log_rate_limit = true
49        );
50        // NOT the actual number of replacements in the output: there's no easy
51        // way to get that from the lib we use here (encoding_rs)
52        counter!("encoder_unmappable_replacement_warnings_total").increment(1);
53    }
54}