vector/internal_events/
tag_cardinality_limit.rs

1use metrics::counter;
2use vector_lib::internal_event::{ComponentEventsDropped, InternalEvent, INTENTIONAL};
3
4pub struct TagCardinalityLimitRejectingEvent<'a> {
5    pub metric_name: &'a str,
6    pub tag_key: &'a str,
7    pub tag_value: &'a str,
8}
9
10impl InternalEvent for TagCardinalityLimitRejectingEvent<'_> {
11    fn emit(self) {
12        debug!(
13            message = "Event containing tag with new value after hitting configured 'value_limit'; discarding event.",
14            metric_name = self.metric_name,
15            tag_key = self.tag_key,
16            tag_value = self.tag_value,
17            internal_log_rate_limit = true,
18        );
19        counter!("tag_value_limit_exceeded_total").increment(1);
20
21        emit!(ComponentEventsDropped::<INTENTIONAL> {
22            count: 1,
23            reason: "Tag value limit exceeded."
24        })
25    }
26}
27
28pub struct TagCardinalityLimitRejectingTag<'a> {
29    pub metric_name: &'a str,
30    pub tag_key: &'a str,
31    pub tag_value: &'a str,
32}
33
34impl InternalEvent for TagCardinalityLimitRejectingTag<'_> {
35    fn emit(self) {
36        debug!(
37            message = "Rejecting tag after hitting configured 'value_limit'.",
38            metric_name = self.metric_name,
39            tag_key = self.tag_key,
40            tag_value = self.tag_value,
41            internal_log_rate_limit = true,
42        );
43        counter!("tag_value_limit_exceeded_total").increment(1);
44    }
45}
46
47pub struct TagCardinalityValueLimitReached<'a> {
48    pub key: &'a str,
49}
50
51impl InternalEvent for TagCardinalityValueLimitReached<'_> {
52    fn emit(self) {
53        debug!(
54            message = "Value_limit reached for key. New values for this key will be rejected.",
55            key = %self.key,
56        );
57        counter!("value_limit_reached_total").increment(1);
58    }
59}