vector/internal_events/
remap.rs

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