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