Skip to content

Commit 4532a24

Browse files
committed
enhancement(observability): Update internal log rate limiting messages
To use the word "suppressed" when messages are being suppressed. This is similar to SystemD and, we think, will be less likely to confuse users into thinking that their event processing is being suppressed. Signed-off-by: Jesse Szwedko <[email protected]>
1 parent 6c57ca0 commit 4532a24

File tree

1 file changed

+46
-47
lines changed

1 file changed

+46
-47
lines changed

lib/tracing-limit/src/lib.rs

+46-47
Original file line numberDiff line numberDiff line change
@@ -177,36 +177,35 @@ where
177177
State::new(message, limit)
178178
});
179179

180-
// Update our rate limiting state for this event, and see if we should still be rate limiting it.
180+
// Update our suppressed state for this event, and see if we should still be suppressing it.
181181
//
182182
// When this is the first time seeing the event, we emit it like we normally would. The second time we see it in
183-
// the limit period, we emit a new event to indicate that the original event is being actively rate limited.
183+
// the limit period, we emit a new event to indicate that the original event is being actively suppressed.
184184
// Otherwise, we don't emit anything.
185185
let previous_count = state.increment_count();
186186
if state.should_limit() {
187187
match previous_count {
188188
0 => self.inner.on_event(event, ctx),
189189
1 => {
190-
let message =
191-
format!("Internal log [{}] is being rate limited.", state.message);
190+
let message = format!("Internal log [{}] is being suppressed.", state.message);
192191
self.create_event(&ctx, metadata, message, state.limit);
193192
}
194193
_ => {}
195194
}
196195
} else {
197196
// If we saw this event 3 or more times total, emit an event that indicates the total number of times we
198-
// rate limited the event in the limit period.
197+
// suppressed the event in the limit period.
199198
if previous_count > 1 {
200199
let message = format!(
201-
"Internal log [{}] has been rate limited {} times.",
200+
"Internal log [{}] has been suppressed {} times.",
202201
state.message,
203202
previous_count - 1
204203
);
205204

206205
self.create_event(&ctx, metadata, message, state.limit);
207206
}
208207

209-
// We're not rate limiting anymore, so we also emit the current event as normal.. but we update our rate
208+
// We're not suppressing anymore, so we also emit the current event as normal.. but we update our rate
210209
// limiting state since this is effectively equivalent to seeing the event again for the first time.
211210
self.inner.on_event(event, ctx);
212211

@@ -510,11 +509,11 @@ mod test {
510509
*events,
511510
vec![
512511
"Hello world!",
513-
"Internal log [Hello world!] is being rate limited.",
514-
"Internal log [Hello world!] has been rate limited 9 times.",
512+
"Internal log [Hello world!] is being suppressed to avoid flooding.",
513+
"Internal log [Hello world!] has been suppressed 9 times.",
515514
"Hello world!",
516-
"Internal log [Hello world!] is being rate limited.",
517-
"Internal log [Hello world!] has been rate limited 9 times.",
515+
"Internal log [Hello world!] is being suppressed to avoid flooding.",
516+
"Internal log [Hello world!] has been suppressed 9 times.",
518517
"Hello world!",
519518
]
520519
.into_iter()
@@ -547,11 +546,11 @@ mod test {
547546
*events,
548547
vec![
549548
"Hello world!",
550-
"Internal log [Hello world!] is being rate limited.",
551-
"Internal log [Hello world!] has been rate limited 9 times.",
549+
"Internal log [Hello world!] is being suppressed to avoid flooding.",
550+
"Internal log [Hello world!] has been suppressed 9 times.",
552551
"Hello world!",
553-
"Internal log [Hello world!] is being rate limited.",
554-
"Internal log [Hello world!] has been rate limited 9 times.",
552+
"Internal log [Hello world!] is being suppressed to avoid flooding.",
553+
"Internal log [Hello world!] has been suppressed 9 times.",
555554
"Hello world!",
556555
]
557556
.into_iter()
@@ -594,29 +593,29 @@ mod test {
594593
"Hello foo on line_number 2!",
595594
"Hello bar on line_number 1!",
596595
"Hello bar on line_number 2!",
597-
"Internal log [Hello foo on line_number 1!] is being rate limited.",
598-
"Internal log [Hello foo on line_number 2!] is being rate limited.",
599-
"Internal log [Hello bar on line_number 1!] is being rate limited.",
600-
"Internal log [Hello bar on line_number 2!] is being rate limited.",
601-
"Internal log [Hello foo on line_number 1!] has been rate limited 9 times.",
596+
"Internal log [Hello foo on line_number 1!] is being suppressed to avoid flooding.",
597+
"Internal log [Hello foo on line_number 2!] is being suppressed to avoid flooding.",
598+
"Internal log [Hello bar on line_number 1!] is being suppressed to avoid flooding.",
599+
"Internal log [Hello bar on line_number 2!] is being suppressed to avoid flooding.",
600+
"Internal log [Hello foo on line_number 1!] has been suppressed 9 times.",
602601
"Hello foo on line_number 1!",
603-
"Internal log [Hello foo on line_number 2!] has been rate limited 9 times.",
602+
"Internal log [Hello foo on line_number 2!] has been suppressed 9 times.",
604603
"Hello foo on line_number 2!",
605-
"Internal log [Hello bar on line_number 1!] has been rate limited 9 times.",
604+
"Internal log [Hello bar on line_number 1!] has been suppressed 9 times.",
606605
"Hello bar on line_number 1!",
607-
"Internal log [Hello bar on line_number 2!] has been rate limited 9 times.",
606+
"Internal log [Hello bar on line_number 2!] has been suppressed 9 times.",
608607
"Hello bar on line_number 2!",
609-
"Internal log [Hello foo on line_number 1!] is being rate limited.",
610-
"Internal log [Hello foo on line_number 2!] is being rate limited.",
611-
"Internal log [Hello bar on line_number 1!] is being rate limited.",
612-
"Internal log [Hello bar on line_number 2!] is being rate limited.",
613-
"Internal log [Hello foo on line_number 1!] has been rate limited 9 times.",
608+
"Internal log [Hello foo on line_number 1!] is being suppressed to avoid flooding.",
609+
"Internal log [Hello foo on line_number 2!] is being suppressed to avoid flooding.",
610+
"Internal log [Hello bar on line_number 1!] is being suppressed to avoid flooding.",
611+
"Internal log [Hello bar on line_number 2!] is being suppressed to avoid flooding.",
612+
"Internal log [Hello foo on line_number 1!] has been suppressed 9 times.",
614613
"Hello foo on line_number 1!",
615-
"Internal log [Hello foo on line_number 2!] has been rate limited 9 times.",
614+
"Internal log [Hello foo on line_number 2!] has been suppressed 9 times.",
616615
"Hello foo on line_number 2!",
617-
"Internal log [Hello bar on line_number 1!] has been rate limited 9 times.",
616+
"Internal log [Hello bar on line_number 1!] has been suppressed 9 times.",
618617
"Hello bar on line_number 1!",
619-
"Internal log [Hello bar on line_number 2!] has been rate limited 9 times.",
618+
"Internal log [Hello bar on line_number 2!] has been suppressed 9 times.",
620619
"Hello bar on line_number 2!",
621620
]
622621
.into_iter()
@@ -658,29 +657,29 @@ mod test {
658657
"Hello foo on line_number 2!",
659658
"Hello bar on line_number 1!",
660659
"Hello bar on line_number 2!",
661-
"Internal log [Hello foo on line_number 1!] is being rate limited.",
662-
"Internal log [Hello foo on line_number 2!] is being rate limited.",
663-
"Internal log [Hello bar on line_number 1!] is being rate limited.",
664-
"Internal log [Hello bar on line_number 2!] is being rate limited.",
665-
"Internal log [Hello foo on line_number 1!] has been rate limited 9 times.",
660+
"Internal log [Hello foo on line_number 1!] is being suppressed to avoid flooding.",
661+
"Internal log [Hello foo on line_number 2!] is being suppressed to avoid flooding.",
662+
"Internal log [Hello bar on line_number 1!] is being suppressed to avoid flooding.",
663+
"Internal log [Hello bar on line_number 2!] is being suppressed to avoid flooding.",
664+
"Internal log [Hello foo on line_number 1!] has been suppressed 9 times.",
666665
"Hello foo on line_number 1!",
667-
"Internal log [Hello foo on line_number 2!] has been rate limited 9 times.",
666+
"Internal log [Hello foo on line_number 2!] has been suppressed 9 times.",
668667
"Hello foo on line_number 2!",
669-
"Internal log [Hello bar on line_number 1!] has been rate limited 9 times.",
668+
"Internal log [Hello bar on line_number 1!] has been suppressed 9 times.",
670669
"Hello bar on line_number 1!",
671-
"Internal log [Hello bar on line_number 2!] has been rate limited 9 times.",
670+
"Internal log [Hello bar on line_number 2!] has been suppressed 9 times.",
672671
"Hello bar on line_number 2!",
673-
"Internal log [Hello foo on line_number 1!] is being rate limited.",
674-
"Internal log [Hello foo on line_number 2!] is being rate limited.",
675-
"Internal log [Hello bar on line_number 1!] is being rate limited.",
676-
"Internal log [Hello bar on line_number 2!] is being rate limited.",
677-
"Internal log [Hello foo on line_number 1!] has been rate limited 9 times.",
672+
"Internal log [Hello foo on line_number 1!] is being suppressed to avoid flooding.",
673+
"Internal log [Hello foo on line_number 2!] is being suppressed to avoid flooding.",
674+
"Internal log [Hello bar on line_number 1!] is being suppressed to avoid flooding.",
675+
"Internal log [Hello bar on line_number 2!] is being suppressed to avoid flooding.",
676+
"Internal log [Hello foo on line_number 1!] has been suppressed 9 times.",
678677
"Hello foo on line_number 1!",
679-
"Internal log [Hello foo on line_number 2!] has been rate limited 9 times.",
678+
"Internal log [Hello foo on line_number 2!] has been suppressed 9 times.",
680679
"Hello foo on line_number 2!",
681-
"Internal log [Hello bar on line_number 1!] has been rate limited 9 times.",
680+
"Internal log [Hello bar on line_number 1!] has been suppressed 9 times.",
682681
"Hello bar on line_number 1!",
683-
"Internal log [Hello bar on line_number 2!] has been rate limited 9 times.",
682+
"Internal log [Hello bar on line_number 2!] has been suppressed 9 times.",
684683
"Hello bar on line_number 2!",
685684
]
686685
.into_iter()

0 commit comments

Comments
 (0)