vector/internal_events/
remap.rs

1use metrics::counter;
2use vector_lib::internal_event::{
3    ComponentEventsDropped, INTENTIONAL, InternalEvent, UNINTENTIONAL, error_stage, error_type,
4};
5
6#[derive(Debug)]
7pub struct RemapMappingError {
8    /// If set to true, the remap transform has dropped the event after a failed
9    /// mapping. This internal event reflects that in its messaging.
10    pub event_dropped: bool,
11    pub error: String,
12}
13
14impl InternalEvent for RemapMappingError {
15    fn emit(self) {
16        error!(
17            message = "Mapping failed with event.",
18            error = ?self.error,
19            error_type = error_type::CONVERSION_FAILED,
20            stage = error_stage::PROCESSING,
21            internal_log_rate_limit = true,
22        );
23        counter!(
24            "component_errors_total",
25            "error_type" => error_type::CONVERSION_FAILED,
26            "stage" => error_stage::PROCESSING,
27        )
28        .increment(1);
29        if self.event_dropped {
30            emit!(ComponentEventsDropped::<UNINTENTIONAL> {
31                count: 1,
32                reason: "Mapping failed with event.",
33            });
34        }
35    }
36}
37
38#[derive(Debug)]
39pub struct RemapMappingAbort {
40    /// If set to true, the remap transform has dropped the event after an abort
41    /// during mapping. This internal event reflects that in its messaging.
42    pub event_dropped: bool,
43}
44
45impl InternalEvent for RemapMappingAbort {
46    fn emit(self) {
47        debug!(
48            message = "Event mapping aborted.",
49            internal_log_rate_limit = true
50        );
51
52        if self.event_dropped {
53            emit!(ComponentEventsDropped::<INTENTIONAL> {
54                count: 1,
55                reason: "Event mapping aborted.",
56            });
57        }
58    }
59}