vector/internal_events/
encoding_transcode.rs

1use vector_lib::{
2    NamedInternalEvent, counter,
3    internal_event::{CounterName, InternalEvent},
4};
5
6#[derive(Debug, NamedInternalEvent)]
7pub struct DecoderBomRemoval {
8    pub from_encoding: &'static str,
9}
10
11impl InternalEvent for DecoderBomRemoval {
12    fn emit(self) {
13        trace!(
14            message = "Removing initial BOM bytes from the final output while decoding to utf8.",
15            from_encoding = %self.from_encoding
16        );
17        counter!(CounterName::DecoderBomRemovalsTotal).increment(1);
18    }
19}
20
21#[derive(Debug, NamedInternalEvent)]
22pub struct DecoderMalformedReplacement {
23    pub from_encoding: &'static str,
24}
25
26impl InternalEvent for DecoderMalformedReplacement {
27    fn emit(self) {
28        warn!(
29            message = "Replaced malformed sequences with replacement character while decoding to utf8.",
30            from_encoding = %self.from_encoding
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!(CounterName::DecoderMalformedReplacementWarningsTotal).increment(1);
35    }
36}
37
38#[derive(Debug, NamedInternalEvent)]
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        );
49        // NOT the actual number of replacements in the output: there's no easy
50        // way to get that from the lib we use here (encoding_rs)
51        counter!(CounterName::EncoderUnmappableReplacementWarningsTotal).increment(1);
52    }
53}