vector/internal_events/
encoding_transcode.rs

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