vector/internal_events/
datadog_metrics.rs

1use metrics::counter;
2use vector_lib::internal_event::InternalEvent;
3use vector_lib::internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL};
4
5#[derive(Debug)]
6pub struct DatadogMetricsEncodingError<'a> {
7    pub reason: &'a str,
8    pub error_code: &'static str,
9    pub dropped_events: usize,
10}
11
12impl InternalEvent for DatadogMetricsEncodingError<'_> {
13    fn emit(self) {
14        error!(
15            message = self.reason,
16            error_code = self.error_code,
17            error_type = error_type::ENCODER_FAILED,
18            intentional = "false",
19            stage = error_stage::PROCESSING,
20            internal_log_rate_limit = true,
21        );
22        counter!(
23            "component_errors_total",
24            "error_code" => self.error_code,
25            "error_type" => error_type::ENCODER_FAILED,
26            "stage" => error_stage::PROCESSING,
27        )
28        .increment(1);
29
30        if self.dropped_events > 0 {
31            emit!(ComponentEventsDropped::<UNINTENTIONAL> {
32                count: self.dropped_events,
33                reason: self.reason,
34            });
35        }
36    }
37}