this post was submitted on 08 Sep 2023
9 points (100.0% liked)

Rust Programming

7734 readers
3 users here now

founded 5 years ago
MODERATORS
 

I've been reading a bit the tracing crate documentation, trying to find out if there's a way to rate limit logs.

What I refer with rate limiting, is that once a particular log has shown up with some frequency (x amount of times in a given time) then it won't be captured or shown anymore, until certain amount of time... This to avoid getting the logs space/buffer being eaten by just one, or a few high frequency errors for example.

Thanks !

top 4 comments
sorted by: hot top controversial new old
[–] [email protected] 5 points 11 months ago (1 children)

This would most certainty be part of the used subscriber. I'm not sure if any of the existing subscribers support it, but in the worst case you can write your own subscriber that wraps an existing one.

[–] [email protected] 1 points 11 months ago

Yeap, I was thinking if perhaps any subscriber would support it, but didn't find any which documents it. Perhaps you're right and subscriber wrapper is needed.

[–] [email protected] 2 points 11 months ago (1 children)

AFAIK it will just print out all the logs it gets. There is no rate limiting. I guess for such a feature someone may need some postprocessing or filtering :/

[–] [email protected] 1 points 11 months ago

OK, thanks !