vector/internal_events/
statsd_sink.rs

1use metrics::counter;
2use vector_lib::internal_event::InternalEvent;
3
4use crate::event::metric::{MetricKind, MetricValue};
5use vector_lib::internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL};
6
7#[derive(Debug)]
8pub struct StatsdInvalidMetricError<'a> {
9    pub value: &'a MetricValue,
10    pub kind: MetricKind,
11}
12
13impl InternalEvent for StatsdInvalidMetricError<'_> {
14    fn emit(self) {
15        let reason = "Invalid metric type received.";
16        error!(
17            message = reason,
18            error_code = "invalid_metric",
19            error_type = error_type::ENCODER_FAILED,
20            stage = error_stage::PROCESSING,
21            value = ?self.value,
22            kind = ?self.kind,
23            internal_log_rate_limit = true,
24        );
25        counter!(
26            "component_errors_total",
27            "error_code" => "invalid_metric",
28            "error_type" => error_type::ENCODER_FAILED,
29            "stage" => error_stage::PROCESSING,
30        )
31        .increment(1);
32
33        emit!(ComponentEventsDropped::<UNINTENTIONAL> { reason, count: 1 });
34    }
35}